Skip to content

Commit

Permalink
Allow multiple packages
Browse files Browse the repository at this point in the history
  • Loading branch information
jspc committed Mar 8, 2022
1 parent fb1b586 commit e3228a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
29 changes: 19 additions & 10 deletions client/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,42 @@ 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)
if err != nil {
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)
},
}

Expand Down
4 changes: 2 additions & 2 deletions client/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
)

Expand Down

0 comments on commit e3228a4

Please sign in to comment.