Skip to content
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

Variable assignments with default values #1350

Open
virtja opened this issue Feb 3, 2025 · 1 comment
Open

Variable assignments with default values #1350

virtja opened this issue Feb 3, 2025 · 1 comment

Comments

@virtja
Copy link

virtja commented Feb 3, 2025

It would be great if it was possible to provide default variable values, so that when new developer comes along, the defaults would be active out-of-the-box with no IDE or environment changes. So far I have not found how to do this.

Rest Client $shared Environment is a good starting point, but as far as I can see, it can only work if .vscode/settings.json file is set under version control system (i.e. commited to repository). But then one cannot set own VS code folder settings, without dealing with further merge issues. The out-of-the-box condition also does not check if developers must copy from custom "template" settings file that is under VCS, for example if $shared environment was encoded in .vscode/settings.copyme.json .

Syntax {{$dotenv variableName}} would be otherwise great, but it does not work if there is no .env file found, which is the default condition, until developer explicitly creates that file.
Something like following would be nice to do:

@myvar = {{$dotenv VALUE_FROM_ENVIRONMENT}} OR "defaultvalue"

or

@myvar = {{$dotenv VALUE_FROM_ENVIRONMENT}}
@myvar ?= "defaultvalue"

It would in addition be nice if {{$dotenv variableName}} could be configured to refer other file than .dot. But this is secondary issue, and I have noted there are other similar feature requests.

Similar problem is with $processEnv, when in default case environment does not contain whatever environment variable is read.

Or maybe I have missed some existing conditional variable assignment syntax ?

@ngdangtu-vn
Copy link

I also would like to see the default value for @prompt var

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants