Coder Social home page Coder Social logo

Comments (6)

DannyBen avatar DannyBen commented on September 25, 2024 1

Excellent. Thanks for confirming. I will release tomorrow.

from bashly.

DannyBen avatar DannyBen commented on September 25, 2024

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.

DannyBen avatar DannyBen commented on September 25, 2024

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.

DannyBen avatar DannyBen commented on September 25, 2024

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.

ChipS3t avatar ChipS3t commented on September 25, 2024

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.

DannyBen avatar DannyBen commented on September 25, 2024

Version 1.0.3 was released, including this fix.

from bashly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.