-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: support for markdown docopts.md
- Loading branch information
1 parent
6656185
commit 79d5b61
Showing
13 changed files
with
266 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
setup() { | ||
load 'test_helper/bats-support/load' | ||
load 'test_helper/bats-assert/load' | ||
export NO_COLOR=1 | ||
} | ||
|
||
@test "legacy docops without markdown" { | ||
# show the legacy docopts.txt | ||
run ops docopts legacy | ||
assert_success | ||
assert_line --partial "legacy simple [-f]" | ||
run ops docopts legacy simple | ||
assert_line --partial "simple without flag" | ||
run ops docopts legacy simple -f | ||
assert_line "simple with flag" | ||
} | ||
|
||
@test "docops with markdown" { | ||
run ops docopts | ||
assert_success | ||
assert_line --partial "--------" | ||
assert_line --partial "Synopsis" | ||
assert_line --partial "simple [-f]" | ||
|
||
run env OPS_NO_DOCOPTS=1 ops docopts simple _f=false | ||
assert_line --partial "Warning: ignoring docopts.md" | ||
assert_line "simple without flag" | ||
run env OPS_NO_DOCOPTS=1 ops docopts simple _f=true | ||
assert_line --partial "Warning: ignoring docopts.md" | ||
assert_line "simple with flag" | ||
|
||
run ops docopts simple | ||
assert_line "simple without flag" | ||
|
||
run ops docopts simple -f | ||
assert_line "simple with flag" | ||
|
||
run ops docopts simple -g | ||
assert_failure | ||
assert_line "Usage:" | ||
assert_line --partial "docopts simple [-f]" | ||
|
||
} | ||
|
||
@test "docops with both" { | ||
# show the docopts.txt with a warning | ||
run ops docopts both | ||
assert_success | ||
refute_line "This should be ignored" | ||
assert_line --partial "both simple [-f]" | ||
assert_line "Warning: both docopts.txt and docopts.md are present, docopts.txt ignored." | ||
|
||
run ops docopts both simple -f | ||
assert_success | ||
assert_line "simple with flag" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Task `docopts both` | ||
|
||
Simple task with flag | ||
|
||
## Synopsis | ||
|
||
```text | ||
Usage: | ||
both simple [-f] | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
This should be ignored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
version: "3" | ||
|
||
tasks: | ||
simple: | ||
silent: true | ||
desc: simple task in other | ||
cmds: | ||
- | | ||
if {{.__f__}} | ||
then echo simple with flag | ||
else echo simple without flag | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Task `docopts` | ||
|
||
Simple task with flag | ||
|
||
## Synopsis | ||
|
||
```text | ||
Usage: | ||
docopts simple [-f] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Task: docopts legacy | ||
|
||
Simple task with flag | ||
|
||
Usage: | ||
legacy simple [-f] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
version: "3" | ||
|
||
tasks: | ||
simple: | ||
silent: true | ||
desc: simple task in other | ||
cmds: | ||
- | | ||
if {{._f}} | ||
then echo simple with flag | ||
else echo simple without flag | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
version: "3" | ||
|
||
tasks: | ||
simple: | ||
silent: true | ||
desc: simple task | ||
cmds: | ||
- | | ||
if {{._f}} | ||
then echo simple with flag | ||
else echo simple without flag | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters