Skip to content

Commit

Permalink
Merge pull request #1484 from nono/improve-cli
Browse files Browse the repository at this point in the history
Improve CLI
  • Loading branch information
jinroh committed Aug 7, 2018
2 parents 37f07a8 + af6e2cd commit e3940b6
Show file tree
Hide file tree
Showing 60 changed files with 125 additions and 164 deletions.
26 changes: 13 additions & 13 deletions cmd/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var flagKonnectorAccountID string
var flagKonnectorsParameters string

var webappsCmdGroup = &cobra.Command{
Use: "apps [command]",
Use: "apps <command>",
Short: "Interact with the applications",
Long: `
cozy-stack apps allows to interact with the cozy applications.
Expand All @@ -38,7 +38,7 @@ a cozy.
}

var triggersCmdGroup = &cobra.Command{
Use: "triggers [command]",
Use: "triggers <command>",
Short: "Interact with the triggers",
Long: `
cozy-stack apps allows to interact with the cozy triggers.
Expand All @@ -51,7 +51,7 @@ It provides command to run a specific trigger.
}

var installWebappCmd = &cobra.Command{
Use: "install [slug] [sourceurl]",
Use: "install <slug> [sourceurl]",
Short: `Install an application with the specified slug name
from the given source URL.`,
Example: "$ cozy-stack apps install --domain cozy.tools:8080 drive registry://drive/stable",
Expand All @@ -62,7 +62,7 @@ from the given source URL.`,
}

var updateWebappCmd = &cobra.Command{
Use: "update [slug] [sourceurl]",
Use: "update <slug> [sourceurl]",
Short: "Update the application with the specified slug name.",
Aliases: []string{"upgrade"},
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -71,7 +71,7 @@ var updateWebappCmd = &cobra.Command{
}

var uninstallWebappCmd = &cobra.Command{
Use: "uninstall [slug]",
Use: "uninstall <slug>",
Short: "Uninstall the application with the specified slug name.",
Aliases: []string{"rm"},
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -88,31 +88,31 @@ var lsWebappsCmd = &cobra.Command{
}

var showWebappCmd = &cobra.Command{
Use: "show [slug]",
Use: "show <slug>",
Short: "Show the application attributes",
RunE: func(cmd *cobra.Command, args []string) error {
return showApp(cmd, args, consts.Apps)
},
}

var showWebappTriggersCmd = &cobra.Command{
Use: "show-from-app [slug]",
Use: "show-from-app <slug>",
Short: "Show the application triggers",
RunE: func(cmd *cobra.Command, args []string) error {
return showWebAppTriggers(cmd, args, consts.Apps)
},
}

var showKonnectorCmd = &cobra.Command{
Use: "show [slug]",
Use: "show <slug>",
Short: "Show the application attributes",
RunE: func(cmd *cobra.Command, args []string) error {
return showApp(cmd, args, consts.Konnectors)
},
}

var konnectorsCmdGroup = &cobra.Command{
Use: "konnectors [command]",
Use: "konnectors <command>",
Short: "Interact with the konnectors",
Long: `
cozy-stack konnectors allows to interact with the cozy konnectors.
Expand All @@ -126,7 +126,7 @@ a cozy.
}

var installKonnectorCmd = &cobra.Command{
Use: "install [slug] [sourceurl]",
Use: "install <slug> [sourceurl]",
Short: `Install a konnector with the specified slug name
from the given source URL.`,
Example: "$ cozy-stack konnectors install --domain cozy.tools:8080 trainline registry://trainline/stable",
Expand All @@ -136,7 +136,7 @@ from the given source URL.`,
}

var updateKonnectorCmd = &cobra.Command{
Use: "update [slug] [sourceurl]",
Use: "update <slug> [sourceurl]",
Short: "Update the konnector with the specified slug name.",
Aliases: []string{"upgrade"},
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -145,7 +145,7 @@ var updateKonnectorCmd = &cobra.Command{
}

var uninstallKonnectorCmd = &cobra.Command{
Use: "uninstall [slug]",
Use: "uninstall <slug>",
Short: "Uninstall the konnector with the specified slug name.",
Aliases: []string{"rm"},
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -162,7 +162,7 @@ var lsKonnectorsCmd = &cobra.Command{
}

var runKonnectorsCmd = &cobra.Command{
Use: "run [slug]",
Use: "run <slug>",
Short: "Run a konnector.",
Long: "Run a konnector named with specified slug using the specified options.",
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// completionCmdGroup represents the completion command
var completionCmd = &cobra.Command{
Use: "completion [shell]",
Use: "completion <shell>",
Short: "Output shell completion code for the specified shell",
Long: `
Output shell completion code for the specified shell (bash or zsh).
Expand Down
8 changes: 4 additions & 4 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

var configCmdGroup = &cobra.Command{
Use: "config [command]",
Use: "config <command>",
Short: "Show and manage configuration elements",
Long: `
cozy-stack config allows to print and generate some parts of the configuration
Expand All @@ -45,7 +45,7 @@ the given parameters to display the configuration.`,
}

var adminPasswdCmd = &cobra.Command{
Use: "passwd [filepath]",
Use: "passwd <filepath>",
Aliases: []string{"password", "passphrase", "pass"},
Short: "Generate an admin passphrase",
Long: `
Expand Down Expand Up @@ -124,7 +124,7 @@ example: cozy-stack config passwd ~/.cozy/
}

var genKeysCmd = &cobra.Command{
Use: "gen-keys [filepath]",
Use: "gen-keys <filepath>",
Short: "Generate an key pair for encryption and decryption of credentials",
Long: `
cozy-stack config gen-keys generate a key-pair and save them in the
Expand Down Expand Up @@ -165,7 +165,7 @@ keyfiles written in:
}

var decryptCredentialsCmd = &cobra.Command{
Use: "decrypt-creds [keyfile] [ciphertext]",
Use: "decrypt-creds <keyfile> <ciphertext>",
Aliases: []string{"decrypt-credentials"},
Short: "Decrypt the given credentials cipher text with the specified decryption keyfile.",
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
6 changes: 3 additions & 3 deletions cmd/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// docCmdGroup represents the doc command
var docCmdGroup = &cobra.Command{
Use: "doc [command]",
Use: "doc <command>",
Short: "Print the documentation",
Long: "Print the documentation about the usage of cozy-stack in command-line",
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -16,7 +16,7 @@ var docCmdGroup = &cobra.Command{
}

var manDocCmd = &cobra.Command{
Use: "man [directory]",
Use: "man <directory>",
Short: "Print the manpages of cozy-stack",
Long: `Print the manual pages for using cozy-stack in command-line`,
Example: `$ mkdir -p ~/share/man
Expand All @@ -36,7 +36,7 @@ $ man cozy-stack`,
}

var markdownDocCmd = &cobra.Command{
Use: "markdown [directory]",
Use: "markdown <directory>",
Short: "Print the documentation of cozy-stack as markdown",
Example: `$ cozy-stack doc markdown docs/cli`,
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
24 changes: 13 additions & 11 deletions cmd/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ var errFilesMissingDomain = errors.New("Missing --domain flag")

const filesExecUsage = `Available commands:
mkdir [name] Creates a directory with specified name
ls [-l] [-a] [-h] [name] Prints the children of the specified directory
tree [name] Prints the tree structure of the specified directory
attrs [name] Prints the attributes of the specified file or directory
cat [name] Echo the file content in stdout
mv [from] [to] Rename a file or directory
rm [-f] [-r] [name] Move the file to trash, or delete it permanently with -f flag
restore [name] Restore a file or directory from trash
mkdir <name> Creates a directory with specified name
ls [-l] [-a] [-h] <name> Prints the children of the specified directory
tree <name> Prints the tree structure of the specified directory
attrs <name> Prints the attributes of the specified file or directory
cat <name> Echo the file content in stdout
mv <from> <to> Rename a file or directory
rm [-f] [-r] <name> Move the file to trash, or delete it permanently with -f flag
restore <name> Restore a file or directory from trash
Don't forget to put quotes around the command!
`
Expand All @@ -47,7 +47,7 @@ var flagImportMatch string

// filesCmdGroup represents the instances command
var filesCmdGroup = &cobra.Command{
Use: "files [command]",
Use: "files <command>",
Short: "Interact with the cozy filesystem",
Long: `
cozy-stack files allows to interact with the cozy filesystem.
Expand All @@ -63,7 +63,7 @@ current filesystem into cozy.
}

var execFilesCmd = &cobra.Command{
Use: "exec [--domain domain] [command]",
Use: "exec [--domain domain] <command>",
Short: "Execute the given command on the specified domain and leave",
Long: "Execute a command on the VFS of the specified domain.\n" + filesExecUsage,
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -85,7 +85,7 @@ var execFilesCmd = &cobra.Command{
}

var importFilesCmd = &cobra.Command{
Use: "import [--domain domain] [--from name] [--to name] [--match pattern]",
Use: "import [--domain domain] [--match pattern] --from <name> --to <name>",
Short: "Import the specified file or directory into cozy",
RunE: func(cmd *cobra.Command, args []string) error {
if flagFilesDomain == "" {
Expand Down Expand Up @@ -480,7 +480,9 @@ func init() {
filesCmdGroup.PersistentFlags().StringVar(&flagFilesDomain, "domain", domain, "specify the domain name of the instance")

importFilesCmd.Flags().StringVar(&flagImportFrom, "from", "", "directory to import from in cozy")
importFilesCmd.MarkFlagRequired("from")
importFilesCmd.Flags().StringVar(&flagImportTo, "to", "/", "directory to import to in cozy")
importFilesCmd.MarkFlagRequired("to")
importFilesCmd.Flags().BoolVar(&flagImportDryRun, "dry-run", false, "do not actually import the files")
importFilesCmd.Flags().StringVar(&flagImportMatch, "match", "", "pattern that the imported files must match")

Expand Down
14 changes: 7 additions & 7 deletions cmd/fixer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ var dryRunFlag bool
var withMetadataFlag bool

var fixerCmdGroup = &cobra.Command{
Use: "fixer [command]",
Use: "fixer <command>",
Short: "A set of tools to fix issues or migrate content for retro-compatibility.",
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Usage()
},
}

var albumsCreatedAtFixerCmd = &cobra.Command{
Use: "albums-created-at [domain]",
Use: "albums-created-at <domain>",
Short: "Add a created_at field for albums where it's missing",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
Expand Down Expand Up @@ -94,7 +94,7 @@ var albumsCreatedAtFixerCmd = &cobra.Command{
}

var md5FixerCmd = &cobra.Command{
Use: "md5 [domain]",
Use: "md5 <domain>",
Short: "Fix missing md5 from contents in the vfs",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
Expand Down Expand Up @@ -142,7 +142,7 @@ var md5FixerCmd = &cobra.Command{
}

var mimeFixerCmd = &cobra.Command{
Use: "mime [domain]",
Use: "mime <domain>",
Short: "Fix the class computed from the mime-type",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
Expand Down Expand Up @@ -174,7 +174,7 @@ var mimeFixerCmd = &cobra.Command{
}

var jobsFixer = &cobra.Command{
Use: "jobs [domain]",
Use: "jobs <domain>",
Short: "Take a look at the consistency of the jobs",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
Expand Down Expand Up @@ -246,7 +246,7 @@ var redisFixer = &cobra.Command{
}

var orphanAccountsFixer = &cobra.Command{
Use: "accounts-orphans [domain]",
Use: "accounts-orphans <domain>",
Aliases: []string{"account-orphans"},
Short: "Rebuild triggers associated with orphan accounts",
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -283,7 +283,7 @@ var orphanAccountsFixer = &cobra.Command{
}

var thumbnailsFixer = &cobra.Command{
Use: "thumbnails [domain]",
Use: "thumbnails <domain>",
Short: "Rebuild thumbnails image for images files",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
Expand Down
Loading

0 comments on commit e3940b6

Please sign in to comment.