Comments (8)
Released 1.0.7 with this feature.
Minimal docs here: https://bashly.dannyb.co/advanced/erb-in-config/
Thanks for the suggestion.
from bashly.
Good idea. Do you have a sample YAML use case?
from bashly.
The implementation is ready if you want to try it.
Let me know if it aligned with your use case.
from bashly.
use case:
commands:
- name: completions
help: |-
Generate bash completions
Usage: eval "\$(ansible completions)"
- name: ansible
help: Ansible related commands
commands:
- name: playbook
help: Run Ansible playbook
flags:
- long: --playbook
short: -p
arg: playbook
help: Playbook name
required: true
repeatable: false
allowed:
<%- Dir['playbooks/**/*.yml'].each do |f| -%>
<%- _, dir, file = f.split('/') -%>
- <%= "#{dir}_#{file}".gsub('_', '-').gsub('.yml', '') %>
<%- end -%>
With a bit of Ruby code :
#!/usr/bin/env ruby
require 'erb'
yaml = ERB.new(File.read('vendor/ansible-cli/bashly.yml'), trim_mode: "-").result
puts yaml
it gives :
- name: playbook
help: Run Ansible playbook
flags:
- long: --playbook
short: -p
arg: playbook
help: Playbook name
required: true
repeatable: false
allowed:
- install-apache
- install-burp
- install-dns
- ...
And users can automagically autocomplete the --playbook
flag :)
from bashly.
Let me know if it aligned with your use case.
it does! thank you! ❤️
from bashly.
Ok cool.
- Note that I did not use the trim mode '-' - I just used the default ERB settings:
bashly/lib/bashly/extensions/yaml.rb
Lines 8 to 10 in 44294bb
if there is any reason to load it differently in your opinion, let me know
- I will release during the weekend
- As I see you have some DevOps template manipulations to deal with - you might be interested in Kojo - I used it a lot to transform Kubernetes manifests into something more human friendly.
- You know you can run
bashly validate --verbose
to see the rendered YAML, yes?
from bashly.
As I see you have some DevOps template manipulations to deal with - you might be interested in Kojo - I used it a lot to transform Kubernetes manifests into something more human friendly.
Seems nice, thank you!
You know you can run
bashly validate --verbose
to see the rendered YAML, yes?
I didn't know, thank you!
from bashly.
As I see you have some DevOps template manipulations to deal with - you might be interested in Kojo - I used it a lot to transform Kubernetes manifests into something more human friendly.
Actually I did something (a bit) similar but in Crystal : https://github.com/jbox-web/envtpl.cr
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
- 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
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.