Closed ianjosephwilson closed 3 years ago
I'm guessing you mean bumpver show
(as is shown in your ansible script).
You might do something like this
$ eval $(bumpver show -n --env); echo $CURRENT_VERSION
2021.1009
I guess I meant more to just make a parallel command since show
behaves so much differently. Sorry its a feature request. I run python scripts for deployment, building and other tasks. I'm not sure how I would eval the output without just parsing it in Python. Maybe I should call into the library directly instead?
I wouldn't bother trying to call the library directly.
Instead of a new subcommand, how about a new parameter for show
like this:
$ bumpver show --var CURRENT_VERSION
2021.1009
Just to clarify, from an API perspective, this specifies a variable/param that is available via bumpver show -n --env
. In this example that variable/param is CURRENT_VERSION
. In my specific case my CURRENT_VERSION
is v202110.0005-alpha
based on my toml file version specs. I would want to access bumpver show --var PEP440_VERSION
, ie. 202110.5a0
.
I'm not super familiar with command line scripts because I do mostly webdev but it seems that when calling a script like this the newline would be dropped so the version could be accessed directly but when calling interactively we'd want the newline otherwise the output seems garbled in the shell. So like echo
we'd want a -n
option.
If you're invoking a subcommand anyway, I think all of this is not worth the overkill.
Something like this should work.
>>> from subprocess import check_output
>>> check_output(['bash', '-c', 'eval $(./ve/bin/bumpver show --no-fetch --env); echo -n $PEP440_VERSION'], text=True)
'2021.1002b0'
I saw that there is a way to print environment variables right now but is there a way to just print the version to stdout?
For example (using version format, using pep440 format, using version format but not including newline):
I do something like this now to parse the version from the output and then pass it into ansible.