diff --git a/client/cmd/install.go b/client/cmd/install.go index b6da8dd..5eefe8e 100644 --- a/client/cmd/install.go +++ b/client/cmd/install.go @@ -44,25 +44,27 @@ var ( // installCmd represents the install command var installCmd = &cobra.Command{ - Use: "install [package name]", - Short: "install packages", - Long: `install packages`, + Use: "install [package name] | [package name] [package name]", + Short: "install package(s)", + Long: `install package(s)`, Args: func(cmd *cobra.Command, args []string) error { argCount := len(args) - if argCount != 1 { + if argCount == 0 { cmd.Usage() - if argCount == 0 { - return fmt.Errorf("missing package") - } + return fmt.Errorf("missing package(s)") + } + + if argCount > 1 && version != "" { + cmd.Usage() - return fmt.Errorf("install requires one package, received %d", argCount) + return fmt.Errorf("setting version with multiple packages makes no sense") } return nil }, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, args []string) (err error) { client, err := newClient(socketAddr) err = errWrap("connecting to vin", err) @@ -70,7 +72,14 @@ var installCmd = &cobra.Command{ return err } - return errWrap("installation", client.install(args[0], version, force)) + for _, pkg := range args { + err = client.install(pkg, version, force) + if err != nil { + break + } + } + + return errWrap("installation", err) }, } diff --git a/client/cmd/root_test.go b/client/cmd/root_test.go index 332ac1e..81501d6 100644 --- a/client/cmd/root_test.go +++ b/client/cmd/root_test.go @@ -6,8 +6,8 @@ import ( ) var ( - defaultExpect = "vin provides package management stuff for vinyl linux\n\nIt offers:\n * Speed and extensibility- no mucking around with byzantine package manager configs\n * Modern tooling- sha and md5 are slow and unwieldly. We've moved on. PGP signing package manifests. Why? Sod it, let git handle it\n * Low barrier to entry for contributing- why are we mucking about with granting access to servers/ mailing lists to make changes? Github/ gitlab/ gitea/ all of these solve these issues better. Slap a reasonably permissive CLA onto a repo somewhere, and let people do what they do.\n\nUsage:\n vin [command]\n\nAvailable Commands:\n advise generate a vin config.toml for this machine\n help Help about any command\n install install packages\n reload trigger a reload of manifests\n version Return server and client version information\n\nFlags:\n --config string config file (default is $HOME/.vin.yaml)\n -h, --help help for vin\n --sock string path to the vin socket file (default \"unix:///var/run/vin.sock\")\n\nUse \"vin [command] --help\" for more information about a command.\n" - defaultInstall = "Usage:\n vin install [package name] [flags]\n\nFlags:\n -f, --force Force installation, even when targets are marked as installed\n -h, --help help for install\n -v, --version string Version constraint to install. This command allows strict versions, such as \"1.2.3\", or loose versions such as \">=1.20, <1.3.5\" (default \"latest\")\n\nGlobal Flags:\n --config string config file (default is $HOME/.vin.yaml)\n --sock string path to the vin socket file (default \"unix:///var/run/vin.sock\")\n" + defaultExpect = "vin provides package management stuff for vinyl linux\n\nIt offers:\n * Speed and extensibility- no mucking around with byzantine package manager configs\n * Modern tooling- sha and md5 are slow and unwieldly. We've moved on. PGP signing package manifests. Why? Sod it, let git handle it\n * Low barrier to entry for contributing- why are we mucking about with granting access to servers/ mailing lists to make changes? Github/ gitlab/ gitea/ all of these solve these issues better. Slap a reasonably permissive CLA onto a repo somewhere, and let people do what they do.\n\nUsage:\n vin [command]\n\nAvailable Commands:\n advise generate a vin config.toml for this machine\n help Help about any command\n install install package(s)\n reload trigger a reload of manifests\n version Return server and client version information\n\nFlags:\n --config string config file (default is $HOME/.vin.yaml)\n -h, --help help for vin\n --sock string path to the vin socket file (default \"unix:///var/run/vin.sock\")\n\nUse \"vin [command] --help\" for more information about a command.\n" + defaultInstall = "Usage:\n vin install [package name] | [package name] [package name] [flags]\n\nFlags:\n -f, --force Force installation, even when targets are marked as installed\n -h, --help help for install\n -v, --version string Version constraint to install. This command allows strict versions, such as \"1.2.3\", or loose versions such as \">=1.20, <1.3.5\" (default \"latest\")\n\nGlobal Flags:\n --config string config file (default is $HOME/.vin.yaml)\n --sock string path to the vin socket file (default \"unix:///var/run/vin.sock\")\n" defaultReload = "" )