Closed g-foster2020 closed 1 year ago
nice way to test it with that sed stuff :)
1. ws alone shall be exit 0 and stdout
❯ bin/workspace 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')
1: ws
1:
1: Sub Commands:
1: self-update Updates the current version of workspace.
1: version
1: global
1: poweroff Completely disable workspace by shutting down all containers
1: create
1: secret
1: config
1: Global Options:
1: -h, --help Show help message
1: -v, --verbose Increase verbosity
1:
❯ echo $?
0
2a. ws --help shall be exit 0 and stdout
❯ bin/workspace --help 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')
1: ws
1:
1: Sub Commands:
1: self-update Updates the current version of workspace.
1: version
1: global
1: poweroff Completely disable workspace by shutting down all containers
1: create
1: secret
1: config
1: Global Options:
1: -h, --help Show help message
1: -v, --verbose Increase verbosity
1:
❯ echo $?
0
2b. ws -h shall be exit 0 and stdout
❯ bin/workspace -h 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')
1: ws
1:
1: Sub Commands:
1: self-update Updates the current version of workspace.
1: version
1: global
1: poweroff Completely disable workspace by shutting down all containers
1: create
1: secret
1: config
1: Global Options:
1: -h, --help Show help message
1: -v, --verbose Increase verbosity
1:
❯ echo $?
0
3a. ws --help command shall be exit 0 and stdout
❯ bin/workspace --help version 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')
1: ws version
1:
1: Usage:
1: ws version [options]
1:
1: Global Options:
1: -h, --help Show help message
1: -v, --verbose Increase verbosity
1:
❯ echo $?
0
3b. ws -h command shall be exit 0 and stdout
❯ bin/workspace -h version 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')
1: ws version
1:
1: Usage:
1: ws version [options]
1:
1: Global Options:
1: -h, --help Show help message
1: -v, --verbose Increase verbosity
1:
❯ echo $?
0
4a. ws --help badcommand shall be exit 127 and stderr
❯ bin/workspace --help badcommand 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')
2:
2: [ERROR] Command "badcommand" not recognised
2:
1: ws
1:
1: Sub Commands:
1: self-update Updates the current version of workspace.
1: version
1: global
1: poweroff Completely disable workspace by shutting down all containers
1: create
1: secret
1: config
1: Global Options:
1: -h, --help Show help message
1: -v, --verbose Increase verbosity
1:
❯ echo $?
127
4b. ws -h badcommand shall be exit 127 and stderr
❯ bin/workspace -h badcommand 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')
2:
2: [ERROR] Command "badcommand" not recognised
2:
1: ws
1:
1: Sub Commands:
1: self-update Updates the current version of workspace.
1: version
1: global
1: poweroff Completely disable workspace by shutting down all containers
1: create
1: secret
1: config
1: Global Options:
1: -h, --help Show help message
1: -v, --verbose Increase verbosity
1:
❯ echo $?
127
5a. ws --help shall not throw an error (command "" does not exist)
❯ bin/workspace --help
ws
Sub Commands:
self-update Updates the current version of workspace.
version
global
poweroff Completely disable workspace by shutting down all containers
create
secret
config
Global Options:
-h, --help Show help message
-v, --verbose Increase verbosity
5b. ws -h shall not throw an error (command "" does not exist)
❯ bin/workspace -h
ws
Sub Commands:
self-update Updates the current version of workspace.
version
global
poweroff Completely disable workspace by shutting down all containers
create
secret
config
Global Options:
-h, --help Show help message
-v, --verbose Increase verbosity
6. ws badcommand shall be exit 127 and stderr
❯ bin/workspace badcommand 2> >(sed 's/^/2: /') > >(sed 's/^/1: /')
2:
2: [ERROR] Command "badcommand" not recognised
2:
1: ws
1:
1: Sub Commands:
1: self-update Updates the current version of workspace.
1: version
1: global
1: poweroff Completely disable workspace by shutting down all containers
1: create
1: secret
1: config
1: Global Options:
1: -h, --help Show help message
1: -v, --verbose Increase verbosity
1:
❯ echo $?
127
- ws badcommand shall be exit 127 and stderr
I was meaning the usage too, since not a function output. However I can accept that's a new feature, just what I was asking for for the exit code ticket so wanted it in 0.3
it should be fairly trivial to add e2e tests for the exit codes
the existing exit code tests are here:
the existing exit code tests are here:
Perfect I will do that.
@dantleech Added tests.
Tests
1. ws alone shall be exit 0 and stdout
2a. ws --help shall be exit 0 and stdout
2b. ws -h shall be exit 0 and stdout
3a. ws --help command shall be exit 0 and stdout
3b. ws -h command shall be exit 0 and stdout
4a. ws --help badcommand shall be exit 127 and stderr
4b. ws -h badcommand shall be exit 127 and stderr
5a. ws --help shall not throw an error (command "" does not exist)
5b. ws -h shall not throw an error (command "" does not exist)
6. ws badcommand shall be exit 127 and stderr
fixes #144