Skip to content

Commit e3940b6

Browse files
authored
Merge pull request #1484 from nono/improve-cli
Improve CLI
2 parents 37f07a8 + af6e2cd commit e3940b6

File tree

60 files changed

+125
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+125
-164
lines changed

cmd/apps.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var flagKonnectorAccountID string
2424
var flagKonnectorsParameters string
2525

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

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

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

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

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

9090
var showWebappCmd = &cobra.Command{
91-
Use: "show [slug]",
91+
Use: "show <slug>",
9292
Short: "Show the application attributes",
9393
RunE: func(cmd *cobra.Command, args []string) error {
9494
return showApp(cmd, args, consts.Apps)
9595
},
9696
}
9797

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

106106
var showKonnectorCmd = &cobra.Command{
107-
Use: "show [slug]",
107+
Use: "show <slug>",
108108
Short: "Show the application attributes",
109109
RunE: func(cmd *cobra.Command, args []string) error {
110110
return showApp(cmd, args, consts.Konnectors)
111111
},
112112
}
113113

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

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

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

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

164164
var runKonnectorsCmd = &cobra.Command{
165-
Use: "run [slug]",
165+
Use: "run <slug>",
166166
Short: "Run a konnector.",
167167
Long: "Run a konnector named with specified slug using the specified options.",
168168
RunE: func(cmd *cobra.Command, args []string) error {

cmd/completion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
// completionCmdGroup represents the completion command
1111
var completionCmd = &cobra.Command{
12-
Use: "completion [shell]",
12+
Use: "completion <shell>",
1313
Short: "Output shell completion code for the specified shell",
1414
Long: `
1515
Output shell completion code for the specified shell (bash or zsh).

cmd/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

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

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

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

167167
var decryptCredentialsCmd = &cobra.Command{
168-
Use: "decrypt-creds [keyfile] [ciphertext]",
168+
Use: "decrypt-creds <keyfile> <ciphertext>",
169169
Aliases: []string{"decrypt-credentials"},
170170
Short: "Decrypt the given credentials cipher text with the specified decryption keyfile.",
171171
RunE: func(cmd *cobra.Command, args []string) error {

cmd/doc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

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

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

3838
var markdownDocCmd = &cobra.Command{
39-
Use: "markdown [directory]",
39+
Use: "markdown <directory>",
4040
Short: "Print the documentation of cozy-stack as markdown",
4141
Example: `$ cozy-stack doc markdown docs/cli`,
4242
RunE: func(cmd *cobra.Command, args []string) error {

cmd/files.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ var errFilesMissingDomain = errors.New("Missing --domain flag")
2727

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

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

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

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

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

cmd/fixer.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ var dryRunFlag bool
2323
var withMetadataFlag bool
2424

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

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

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

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

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

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

285285
var thumbnailsFixer = &cobra.Command{
286-
Use: "thumbnails [domain]",
286+
Use: "thumbnails <domain>",
287287
Short: "Rebuild thumbnails image for images files",
288288
RunE: func(cmd *cobra.Command, args []string) error {
289289
if len(args) != 1 {

0 commit comments

Comments
 (0)