File tree 3 files changed +32
-2
lines changed
3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -4,18 +4,22 @@ Feature: CLI
4
4
Scenario : When passing no arguments to the msync command
5
5
When I run `msync`
6
6
And the output should match /Commands:/
7
+ Then the exit status should be 1
7
8
8
9
Scenario : When passing invalid arguments to the msync update command
9
10
When I run `msync update`
10
11
And the output should match /No value provided for required option/
12
+ Then the exit status should be 1
11
13
12
14
Scenario : When passing invalid arguments to the msync hook command
13
15
When I run `msync hook`
14
16
And the output should match /Commands:/
17
+ Then the exit status should be 1
15
18
16
- Scenario : When running the help subcommand
19
+ Scenario : When running the help command
17
20
When I run `msync help`
18
21
And the output should match /Commands:/
22
+ Then the exit status should be 0
19
23
20
24
Scenario : When overriding a setting from the config file on the command line
21
25
Given a puppet module "puppet-test" from "fakenamespace"
Original file line number Diff line number Diff line change 1
1
require 'thor'
2
+
2
3
require 'modulesync'
4
+ require 'modulesync/cli/thor'
3
5
require 'modulesync/constants'
4
6
require 'modulesync/util'
5
7
6
8
module ModuleSync
7
- class CLI
9
+ module CLI
8
10
def self . defaults
9
11
@defaults ||= Util . symbolize_keys ( Util . parse_config ( Constants ::MODULESYNC_CONF_FILE ) )
10
12
end
Original file line number Diff line number Diff line change
1
+ require 'thor'
2
+ require 'modulesync/cli'
3
+
4
+ module ModuleSync
5
+ module CLI
6
+ # Workaround some, still unfixed, Thor behaviors
7
+ #
8
+ # This class extends ::Thor class to
9
+ # - exit with status code sets to `1` on Thor failure (e.g. missing required option)
10
+ # - exit with status code sets to `1` when user calls `msync` (or a subcommand) without required arguments
11
+ class Thor < ::Thor
12
+ desc '_invalid_command_call' , 'Invalid command' , hide : true
13
+ def _invalid_command_call
14
+ self . class . new . help
15
+ exit 1
16
+ end
17
+ default_task :_invalid_command_call
18
+
19
+ def self . exit_on_failure?
20
+ true
21
+ end
22
+ end
23
+ end
24
+ end
You can’t perform that action at this time.
0 commit comments