subcommand

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cdi = &cli.Command{
	Name:   "cdi",
	Usage:  "[unimplemented] manage opencdi stack",
	Action: unimplemented,
	Hidden: true,
}
View Source
var Config = &cli.Command{
	Name:   "config",
	Usage:  "[unimplemented] manage running configuration",
	Action: unimplemented,
	Hidden: true,
}
View Source
var Copy = &cli.Command{
	Name:        "copy",
	Usage:       "[unimplemented] copy resources between host and containers",
	Description: "copy resources between host and containers, or between containers",
	Action:      unimplemented,
	Hidden:      true,
}
View Source
var Images = &cli.Command{
	Name:        "images",
	Usage:       "list and filter images with fuzzy name matching",
	Description: "list and filter images with fuzzy name matching",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "with-id",
			Aliases: []string{"id"},
			Value:   false,
		},
	},
	Action: func(cli *cli.Context) error {
		var filter string
		if cli.NArg() == 0 {
			filter = "."
		} else {
			filter = cli.Args().Get(0)
		}
		return Platform.ImageList(cli.Bool("with-id"), filter)
	},
}
View Source
var List = &cli.Command{
	Name:        "list",
	Usage:       "list and filter containers with fuzzy name matching",
	Description: "list and filter containers with fuzzy name matching",
	Action: func(cli *cli.Context) error {
		var filter string
		if cli.NArg() == 0 {
			filter = "."
		} else {
			filter = cli.Args().Get(0)
		}
		return Platform.ContainerList(
			cli.Bool("all"),
			cli.Bool("with-id"),
			filter,
		)
	},
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "all",
			Aliases: []string{"a"},
			Usage:   "list all containers",
			Value:   false,
		},
		&cli.BoolFlag{
			Name:    "with-id",
			Aliases: []string{"id"},
			Usage:   "show id with the list",
			Value:   false,
		},
	},
}
View Source
var Platform = functions.NewProvider("docker")
View Source
var Run = &cli.Command{
	Name:  "run",
	Usage: "run a container with the specified image",
	Action: func(cli *cli.Context) error {
		if cli.NArg() == 0 {

			return errors.New(cli.App.Name + " run needs image name")
		} else {
			cmd := cli.Args().Slice()[1:]
			if len(cmd) == 0 {
				cmd = []string{"/bin/sh"}
			}
			return Platform.ContainerRun(
				cli.Args().Get(0),
				cli.Bool("persistent"),
				cmd,
			)
		}
	},
	ArgsUsage: "<image> [command] [args...]",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "persistent",
			Aliases: []string{"P"},
			Usage:   "make a non-temporary container",
			Value:   false,
		},
		&cli.StringFlag{
			Name:   "v",
			Usage:  "[disabled] specify the `volume:path` to attach to the container",
			Hidden: true,
		},
		&cli.StringFlag{
			Name:   "device",
			Usage:  "[disabled] specify device `path` to attach to the container",
			Hidden: true,
		},
	},
}
View Source
var Stop = &cli.Command{
	Name:        "stop",
	Usage:       "stop containers with fuzzy name matching",
	Description: "stop containers with fuzzy name matching",
	Action: func(cli *cli.Context) error {
		if cli.NArg() == 0 {
			return errors.New("no arg")
		} else {
			args := cli.Args().Slice()
			for i := range args {
				if err := Platform.ContainerStop(args[i]); err != nil {
					return err
				}
			}
			return nil
		}
	},
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name: "all",
		},
	},
}
View Source
var Version = &cli.Command{
	Name:  "version",
	Usage: "show version",
	Action: func(cli *cli.Context) error {
		fmt.Printf(
			"%s-%s\n",
			cli.App.Name,
			strings.TrimLeft(cli.App.Version, "v"),
		)
		return nil
	},
	ArgsUsage: " ",
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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