Display netlab defaults as (exported) environment variables#3413
Open
ipspace wants to merge 1 commit into
Open
Display netlab defaults as (exported) environment variables#3413ipspace wants to merge 1 commit into
ipspace wants to merge 1 commit into
Conversation
This commit adds '--format' parameter to 'netlab defaults' to display selected netlab defaults in YAML format or as shell environment variables.
There was a problem hiding this comment.
Pull request overview
This PR extends the netlab defaults CLI to support alternate output formats intended for automation, allowing selected defaults to be displayed as YAML or as shell environment variable assignments (optionally prefixed with export).
Changes:
- Added
--format {yaml,env,export}option tonetlab defaultsfor alternate “show” output. - Implemented formatting logic to emit YAML-like
key: valuelines orNETLAB_...=...assignments. - Updated
docs/netlab/defaults.mdto document the new option and provide examples.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| netsim/cli/defaults.py | Adds --format parsing and output formatting logic for defaults display. |
| docs/netlab/defaults.md | Documents the new --format option and shows example outputs. |
| if not args.format: | ||
| print(f'{k} = {v}') | ||
| elif args.format == 'yaml': | ||
| print(f'{k}: {shlex.quote(v) if isinstance(v,str) else v}') |
| key = 'NETLAB_'+k.replace('_','__').replace('.','_').upper() | ||
| if args.format == 'export': | ||
| key = 'export '+key | ||
| print(f'{key}={shlex.quote(v) if isinstance(v,str) else v}') |
Comment on lines
260
to
+263
| if def_expanded: | ||
| print_def_list(def_expanded,args.source) | ||
| if args.source and args.format: | ||
| log.fatal('Cannot use --source option together with --format') | ||
| print_def_list(def_expanded,args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds '--format' parameter to 'netlab defaults' to display selected netlab defaults in YAML format or as shell environment variables.