Comments (6)
Excellent. Thanks for confirming. I will release tomorrow.
from bashly.
Well, this is by design.
Setting the allowed
whitelist, means the variable you receive in your script will always only be one of the allowed options - so it either needs to be required
, or have a default
value, or provided by the user.
The docs are not wrong in stating it can be used with either default
or required
. There is no need to ever specify required: false
, only required: true
since false is the default.
In your use case, allowing the --exclude
flag to receive a none
value, is the way to solve this.
The user does not need to specify --exclude none
, since you make it the default.
name: download
help: Sample minimal application without commands
version: 0.1.0
args:
- name: source
help: URL to download from
default: sphinx
allowed: [sphinx, abc, wonder]
flags:
- long: --exclude
short: -e
arg: action
help: Avoid executing this action
default: none
allowed: [a, b, c, none]
You can see all the combinations of allowed
and required
/default
in the whitelist example.
I will look into it a little deeper, to see if there is a path to modifying this behavior without opening a can of worms.
from bashly.
Well - I am not happy with what I just did....
Your comment about repeatable
that makes it work as expected makes your point more obvious.
I will attempt to make it work as you expect.
from bashly.
This is fixed in the master branch. Can you review and/or test that it matches your expectation?
You can run the unreleased version using one of these ways.
from bashly.
I can confirm this now works as expected.
If the flag or arg sections of the bashly.yml
file contain an allowed
option and required: true
is not set, the argument or flag is optional as expected and will no longer throw an error if a value is not provided on the command line without the need for the default
option.
from bashly.
Version 1.0.3 was released, including this fix.
from bashly.
Related Issues (20)
- Add support for recursive --help HOT 6
- Build multi-arch docker HOT 2
- Default argument is not validated HOT 6
- Flag arguments with a single hyphen prefix are not working HOT 1
- bash completions can't work properly when the position args used 'allowed:' HOT 3
- Repeatable args don't escape quotation marks HOT 12
- Add option to disable splitting of flags with value for catch_all arguments HOT 9
- Lifecycle for temporary directories HOT 1
- Heredoc indentation issue in bashly generated functions. HOT 9
- The Flag value is detected as an Argument HOT 2
- Showing an additional usage line for forced commands HOT 3
- Is it possible to have no command and take arguments from user ? HOT 3
- Shellcheck failure on repeatable argument with allowed values HOT 3
- Default command is not triggered when only flags are provided HOT 1
- using bashly without ruby or docker HOT 3
- Bashly generated script fails shellcheck rule SC2059 HOT 11
- Allow semi-private commands HOT 5
- THIS_SCRIPT variable HOT 4
- Bug in ini library HOT 10
- eval in .zshrc triggers initialise.sh unexpectedly – Is this intended behavior? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bashly.