Comments (5)
Have you tried to use string concatenation in option 1?
--ssc-network-info '[{"port": 444, "ipaddr-type": "static", "vlan-id": '$vlan_id', "static-ip-info": {"type": "ipv4", "ip-address": "'$ip_address'"}}]'
You need to put the shell variables in single quotation marks (basically end and start the string again). But at least bash typically concatenates everything and passes it as a single string to the program
from zhmccli.
Another observation: Option 2 looks very similar to the single line syntax of YAML. The most obvious difference is that you need commas between fields of an object and use :
instead of =
from zhmccli.
Option 3: Single line YAML (aka "Flow Style")
The YAML spec calls this Flow Collection Styles.
Some sources claim that quotes around property names and string values would be needed, but that does not seem to be the case. Example: https://yaml-online-parser.appspot.com/?yaml=prop%3A+%7Bresult%3A+42%2C+name%3A+alice%7D%0A&type=json
Also the YAML spec confirms that no quotes are needed, see Example 7.15: https://yaml.org/spec/1.2.2/#rule-ns-s-flow-map-entries
Note that the flow collection style YAML is a superset of JSON, so double quotes around property names and string values can also be used.
Example for "ssc-network-info":
--ssc-network-info "[{port: 444, ipaddr-type: static, vlan-id: 53, static-ip-info: {type: ipv4, ip-address: '10.11.12.13'}}]"
Example for "ssc-network-info" when using shell/env variables:
--ssc-network-info "[{port: 444, ipaddr-type: static, vlan-id: $vlan_id, static-ip-info: {type: ipv4, ip-address: '$ip_address'}}]"
Examples with a (fantasy) escaped string value:
--properties '{description: ab\ncd}'
--properties "{description: ab\\ncd}"
I must say, I like option 3 the best.
We probably need to write a help topic with a short explanation of the syntax, since the YAML spec is hard to read for occasional users.
More understandable descriptions of flow style that we could refrence:
Probably not so good:
- https://www.tutorialspoint.com/yaml/yaml_flow_styles.htm - shows the optional !!xxx YAML qualifiers
- https://tutorialreference.com/yaml/styles/yaml-flow-style - shows the optional !!xxx YAML qualifiers
- https://dev.to/this-is-learning/yaml-collections-sequences-and-mappings-4meb - not only about flow style
from zhmccli.
I have implemented option 3 in PR #537 - if we agree on that PR, I consider the decision made for using option 3.
from zhmccli.
We agreed on PR #537, so we will continue using option 3 in the future.
This issue is now complete.
from zhmccli.
Related Issues (20)
- "zhmc user create --like ..." fails for non-LDAP or non-MFA users
- Support for a "console delete-uninstalled-firmware" command
- New commands to list EC levels for CPC and console
- Support for listing the supported API features HOT 1
- Use released zhmcclient 1.13.4
- zhmc command as an executable file
- Adding partition to CPC autostart list fails with partition not found.
- Fix badge formatting on readme page
- Improve "zhmc cpc dpm-import"
- Add tests for Python 3.13-beta.1
- Drop support for Python < 3.8
- Migrate to pyproject.toml
- Add support for running the ruff checker
- Add support for running the bandit checker
- Use official Python 3.13 for testing once released
- Use zhmcclient 1.17.0 and stomp-py 8.1.1 HOT 1
- Simplify the syntax for single crypto adapter or single domain range in crypto commands
- Add docker image for running zhmccli HOT 1
- Migrate to using towncrier for change logs
- Simplify releasing and starting a version
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 zhmccli.