Help us shape the future of Go! Take the 2026 Go Developer Survey

command

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package command analyse les arguments d'une commande docker ou docker compose.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GlobalEnd added in v0.3.0

func GlobalEnd(args []string) int

GlobalEnd renvoie l'indice du premier argument qui suit les options globales de la CLI Docker (--context x, -H hôte, --tlsverify…) placées en tête de args.

func TakesValue added in v0.3.0

func TakesValue(subcommand, name string) bool

TakesValue indique si l'option name (sans tirets) de la sous-commande attend une valeur.

Types

type Command

type Command struct {
	Family       Family
	Subcommand   string            // run, build, pull, up, « network rm »…
	Flags        map[string]string // nom sans tirets → valeur (vide pour un booléen), masquée si sensible
	Positionals  []string          // arguments hors options (image, conteneur, commande…)
	ComposeFiles []string          // fichiers passés par -f/--file à docker compose
	Interactive  bool              // la commande utilise le terminal (stderr non capturé)
}

Command est la commande analysée, dérivée des arguments capturés (sans « docker »).

func Parse

func Parse(args []string) Command

Parse analyse les arguments d'une commande docker (sans le mot « docker »). Les valeurs sensibles sont masquées dès l'analyse.

func (Command) Image

func (c Command) Image() string

Image renvoie l'image visée par la commande, si la sous-commande en désigne une.

type Family

type Family string

Family distingue les commandes docker des commandes docker compose.

const (
	FamilyDocker  Family = "docker"
	FamilyCompose Family = "compose"
)

type Layout added in v0.3.0

type Layout struct {
	Subcommand string
	OptsStart  int // indice du premier argument après la sous-commande
	Target     int // indice du premier argument positionnel (image, conteneur…) ; -1 si absent
}

Layout situe les éléments d'une ligne docker : sous-commande, premier argument après la sous-commande et cible (image pour run/create, conteneur pour exec).

func Locate added in v0.3.0

func Locate(args []string) Layout

Locate situe la sous-commande et sa cible dans args, sans masquer ni modifier les arguments (les indices désignent args tel quel).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL