mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 15:43:21 +00:00
Merge pull request #207 from MichaelEischer/err-on-args
Error out on unexpected command line argument
This commit is contained in:
commit
7f29dcbd69
2 changed files with 12 additions and 1 deletions
5
changelog/unreleased/pull-207
Normal file
5
changelog/unreleased/pull-207
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Change: Return error if command-line arguments are specified
|
||||||
|
|
||||||
|
The rest-server ignores command-line arguments. To prevent usage errors it not fails with an error instead of silently ignoring the arguments.
|
||||||
|
|
||||||
|
https://github.com/restic/rest-server/pull/207
|
|
@ -23,6 +23,12 @@ var cmdRoot = &cobra.Command{
|
||||||
SilenceErrors: true,
|
SilenceErrors: true,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
RunE: runRoot,
|
RunE: runRoot,
|
||||||
|
Args: func(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) != 0 {
|
||||||
|
return fmt.Errorf("rest-server expects no arguments - unknown argument: %s", args[0])
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
Version: fmt.Sprintf("rest-server %s compiled with %v on %v/%v\n", version, runtime.Version(), runtime.GOOS, runtime.GOARCH),
|
Version: fmt.Sprintf("rest-server %s compiled with %v on %v/%v\n", version, runtime.Version(), runtime.GOOS, runtime.GOARCH),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue