-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
did-you-mean
for clap-rs
#103
Changes from 13 commits
2592a6f
523ebe1
69827f5
9cb4d13
953e6c7
8c8c812
293c51a
34f801a
311ec16
aa29b32
a13a7d1
4a8e953
c516e1d
688d429
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
language: rust | ||
rust: | ||
- nightly | ||
- beta | ||
- nightly | ||
- beta | ||
before_script: | ||
- git clone --depth 1 https://github.com/kbknapp/travis-cargo | ||
- ln -s ./travis-cargo/travis-cargo.py tc | ||
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH | ||
script: | ||
- | | ||
./tc cargo build && | ||
./tc cargo test && | ||
./tc cargo doc | ||
- travis-cargo build | ||
- travis-cargo test | ||
- make -C clap-tests test | ||
- travis-cargo doc | ||
after_success: | ||
- "./tc --only beta doc-upload" | ||
- travis-cargo --only beta doc-upload | ||
env: | ||
global: | ||
secure: JLBlgHY6OEmhJ8woewNJHmuBokTNUv7/WvLkJGV8xk0t6bXBwSU0jNloXwlH7FiQTc4TccX0PumPDD4MrMgxIAVFPmmmlQOCmdpYP4tqZJ8xo189E5zk8lKF5OyaVYCs5SMmFC3cxCsKjfwGIexNu3ck5Uhwe9jI0tqgkgM3URA= |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,14 @@ | ||
THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) | ||
THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) | ||
URL:= | ||
BRANCH:= | ||
.PHONY: build test clean | ||
|
||
build: | ||
cargo update | ||
@# It may be that this project was never built, and no Cargo.lock exists. | ||
@# Thus it may be ignored | ||
cargo update 2>/dev/null || : | ||
cargo build --release | ||
|
||
test: | ||
cd "$(THIS_DIR)" | ||
cp Cargo.toml cargo.bak | ||
@read -p "Fork URL: " URL; \ | ||
sed "/^git/c\git = \"$$URL\"" cargo.bak > Cargo.toml | ||
@read -p "Branch [master]: " BRANCH; \ | ||
$(if $(strip $(BRANCH)), \ | ||
sed -i "/^branch/c\branch = \"master\"" Cargo.toml, \ | ||
sed -i "/^branch/c\branch = \"$$BRANCH\"" Cargo.toml) | ||
(make clean) || (make clean && false) | ||
cd "$(THIS_DIR)" | ||
(make build) || (make clean && false) | ||
cd "$(THIS_DIR)" | ||
(./run_tests.py) || (make clean && false) | ||
mv cargo.bak Cargo.toml | ||
make clean | ||
|
||
$(MAKE) build || ($(MAKE) clean && false) | ||
./run_tests.py | ||
|
||
clean: | ||
cd "$(THIS_DIR)" | ||
cargo clean |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
--multvalsmo <one> <two> Tests mutliple values, not mult occs | ||
-o, --option <opt>... tests options | ||
--long-option-2 <option2> tests long options with exclusions | ||
-O <option3> tests options with specific value sets [values: fast slow] | ||
-O, --Option <option3> tests options with specific value sets [values: fast slow] | ||
|
||
POSITIONAL ARGUMENTS: | ||
positional tests positionals | ||
|
@@ -35,6 +35,22 @@ | |
help Prints this message | ||
subcmd tests subcommands''' | ||
|
||
_sc_dym_usage = '''Subcommand "subcm" is unknown. Did you mean "subcmd" ? | ||
USAGE: | ||
\tclaptests [POSITIONAL] [FLAGS] [OPTIONS] [SUBCOMMANDS] | ||
For more information try --help''' | ||
|
||
_arg_dym_usage = '''The argument --optio isn't valid. Did you mean --option ? | ||
USAGE: | ||
\tclaptests | ||
For more information try --help''' | ||
|
||
_pv_dym_usage = '''"slo" isn't a valid value for '--Option <option3>' | ||
\t[valid values: fast slow]. Did you mean "slow" ? | ||
USAGE: | ||
\tclaptests --Option <option3> | ||
For more information try --help''' | ||
|
||
_excluded = '''The argument '--flag' cannot be used with '-F' | ||
USAGE: | ||
\tclaptests [positional2] -F --long-option-2 <option2> | ||
|
@@ -213,13 +229,16 @@ | |
'mult_valsmo x2-1: ': ['{} --multvalsmo some other --multvalsmo some'.format(_bin), _mult_vals_2m1], | ||
'mult_valsmo x1: ': ['{} --multvalsmo some other'.format(_bin), _exact], | ||
'F2(ss),O(s),P: ': ['{} value -f -f -o some'.format(_bin), _f2op], | ||
'arg dym: ': ['{} --optio=foo'.format(_bin), _arg_dym_usage], | ||
'pv dym: ': ['{} --Option slo'.format(_bin), _pv_dym_usage], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, here I see a white-space error. My editor used spaces for a while, which is standard for python, whereas the file used tabs. This went unnoticed as it's apparently not an error to do that while defining a dict. |
||
'O2(ll)P: ': ['{} value --option some --option other'.format(_bin), _o2p], | ||
'O2(l=l=)P: ': ['{} value --option=some --option=other'.format(_bin), _o2p], | ||
'O2(ss)P: ': ['{} value -o some -o other'.format(_bin), _o2p], | ||
'F2(s2),O(s),P: ': ['{} value -ff -o some'.format(_bin), _f2op], | ||
'F(s),O(s),P: ': ['{} value -f -o some'.format(_bin), _fop], | ||
'F(l),O(l),P: ': ['{} value --flag --option some'.format(_bin), _fop], | ||
'F(l),O(l=),P: ': ['{} value --flag --option=some'.format(_bin), _fop], | ||
'sc dym: ': ['{} subcm'.format(_bin), _sc_dym_usage], | ||
'sc help short: ': ['{} subcmd -h'.format(_bin), _schelp], | ||
'sc help long: ': ['{} subcmd --help'.format(_bin), _schelp], | ||
'scF(l),O(l),P: ': ['{} subcmd value --flag --option some'.format(_bin), _scfop], | ||
|
@@ -241,7 +260,7 @@ | |
|
||
def pass_fail(name, check, good): | ||
global failed | ||
print(name, end='') | ||
sys.stdout.write(name) | ||
if check == good: | ||
print('Pass') | ||
return | ||
|
@@ -251,9 +270,9 @@ def pass_fail(name, check, good): | |
|
||
def main(): | ||
for cmd, cmd_v in cmds.items(): | ||
with subprocess.Popen(cmd_v[0], shell=True, stdout=subprocess.PIPE, universal_newlines=True) as proc: | ||
out = proc.communicate()[0].strip() | ||
pass_fail(cmd, out, cmd_v[1]) | ||
proc = subprocess.Popen(cmd_v[0], shell=True, stdout=subprocess.PIPE, universal_newlines=True) | ||
out = proc.communicate()[0].strip() | ||
pass_fail(cmd, out, cmd_v[1]) | ||
if failed: | ||
print('One or more tests failed') | ||
return 1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"is unknown" -> "isn't valid" to stick with previous errors