Comments (6)
Nevermind - I see the problem.
# bashly.yml
name: cli
help: Sample application
version: 0.1.0
args:
- name: file
default: README.md
validate: file_exists
with bashly add validations
.
I will need to refactor the validations to run after the conversion of the command input to the args
array.
from bashly.
See #493, which should fix the problem.
Can you test with the edge version?
from bashly.
Alright. I will release in a few days (allowing more time for more commits). Thanks for the report.
from bashly.
A default value is by definition, allowed.
I need an example (minimal bashly.yml and other reproduction steps, if any).
from bashly.
Thank you for the swift response. Here's what I am working on. go-yq arch package is a dependency.
# bashly.yml
name: hyprmenu-power
help: Power Menu
version: 0.1.0
commands:
- name: show
alias: d
help: Show power menu
default: force
args:
- name: config
required: false
help: Path to config file
default: /usr/local/etc/hyprmenu/power.yaml
validate: file_exists
validate: config_format
examples:
- hyprmenu-power show
- hyprmenu-power show /usr/local/etc/hyprmenu/power.yaml
# src/lib/validations/validate_config_format.yaml
validate_config_format() {
[[ $(yq eval ".confirmation_menu.labels | length" $1) -eq 2 ]] || echo "incorrect length of confirmation menu labels in $1"
[[ $(yq eval ".main_menu.labels | length" $1) -eq $(yq eval ".main_menu.confirmations | length" $1) \
&& $(yq eval ".main_menu.labels | length" $1) -eq $(yq eval ".main_menu.commands | length" $1) ]] \
|| echo "Unmatching length of main menu labels, confirmation and commands in $1"
}
# /usr/local/etc/hyprmenu/power.yaml
confirmation_menu:
labels:
- Yes
- No
- test
main_menu:
labels:
- ⭘ Power Off
- ⏼ Reboot
- ⏾ Suspend
- Hibernate
- End Session
- Lock Screen
confirmations:
- true
- true
- false
- false
- true
- false
commands:
- systemctl poweroff
- systemctl reboot
- systemctl suspend
- systemctl hibernate
- hyprctl dispatch exit
- swaylock
The custom validation should check and fail if the confirmation_menu labels array does not have two items. Inserted - test
to force a failure. Both tests should fail, in my opinion. However, with a default value being applied, the validation is skipped.
./hyprmenu-power show
args:
- ${args[config]} = /usr/local/etc/hyprmenu/power.yaml
./hyprmenu-power show /usr/local/etc/hyprmenu/power.yaml
validation error in CONFIG:
incorrect length of confirmation menu labels in /usr/local/etc/hyprmenu/power.yaml
from bashly.
See #493, which should fix the problem. Can you test with the edge version?
Fully tested and working. Thank you so much.
Important to note, there is an error in my shared bashly.yml
from prior comment. References to multiple validations does not work. That was an error in my part, misunderstanding of usage. I combined the validations into one single validation file and all works well.
from bashly.
Related Issues (20)
- Allow default array when repeatable is true HOT 9
- Add support for array in `flag.default` and `arg.default` schema HOT 1
- JSON schema validation passes when it shouldn't HOT 12
- Add JSON schema tests to ensure the validation fails when it should HOT 1
- Whitelisted arg with default from environment HOT 6
- Add `environment_variable.allowed` whitelist HOT 1
- Update `inspect_args` to also print managed environment variables HOT 1
- Docker container does not have pandoc installed HOT 2
- Do not render `inspect_args` when `env` is set to `production` HOT 2
- Add key-value parameters HOT 6
- Add support for recursive --help HOT 6
- Build multi-arch docker HOT 2
- 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
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.