-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add positional argument to env
commands for project
#6387
Conversation
cli/cmd/env/set.go
Outdated
|
||
setCmd := &cobra.Command{ | ||
Use: "set <key> <value>", | ||
Args: cobra.ExactArgs(2), | ||
Use: "set [<project-name>] [--env=key=value]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Did you consider
set [<project>] <key> <value>
, similar to e.g.rill project describe
(link)? Not necessarily saying that's better, just curious which approach you think is more idiomatic? (IMO neither mixed required/optional positional args nor required flags feel intuitive, but can't think of other alternatives.) - If you go ahead with this approach, note there are some non-generated docs that need to be updated (search
docs/
forrill env set
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I see what you mean, I think I will stub it out and try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rill env set some-project key value
Updated project variables
rill env show some-project
NAME VALUE ENVIRONMENT
---------- ------------ -------------
key value
TEST_KEY TEST_VALUE
or assumed in dir
rill env set key value
Updated project variables
rill env show some-project
NAME VALUE ENVIRONMENT
---------- ------------ -------------
key value
TEST_KEY TEST_VALUE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normalized on 1.
cli/cmd/env/show.go
Outdated
if cmd.Flags().Changed("env") { | ||
printEnv(envVars) | ||
} else { | ||
ch.PrintData(envVars) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few thoughts:
- Using
--env
for this maybe feels confusing because we use--env
to specify variable values in a couple other commands - I wonder if people generally would prefer the shell export format instead of a table? I know I would. We could just have that as the only format if you agree.
- The
printEnv
function does not includev.Environment
in the output (it allows for environment-specific overrides of variable values). One idea is to group using comments in the output, like this:
foo=bar
hello=world
# development
foo=bazz
# production
foo=foo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Agreed I'll adjust that
- I had the exact same thought I figured the use case would be to pipe to a dotenv or vault
- I think that is reasonable ~ is it worth providing a filter on that? ~ specify env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is reasonable ~ is it worth providing a filter on that? ~ specify env
It kind of already does with the rill env show --environment
flag. I say "kind of" because if an environment is provided, it actually evaluates the variables for that environment, i.e. it will return non-environment specific variables overwritten by the variables for the requested environment.
Sounds like this isn't completely clear – if you have any ideas for help menu or docs improvements here, feel free to send a PR :)
Co-authored-by: Benjamin Egelund-Müller <[email protected]>
Co-authored-by: Benjamin Egelund-Müller <[email protected]>
Description
Normalizing
env
command usage to howproject
is implemented.rill env
supports flag and positional argrill env show --org=demo --project=rill-openrtb-prog-ads
rill env show rill-openrtb-prog-ads --org=demo
--env
flag allows for the export of.env
output# Example: rill env show rill-openrtb-prog-ads --org=demo --env > .env rill env show rill-openrtb-prog-ads --org=demo --env TEST_KEY=TEST_VALUE
Additionally the character row count was increased https://github.com/lensesio/tableprinter/blob/master/tableprinter.go#L83-L84