digitalmars.D - Get variables from dub.json
- dog2002 (3/3) Mar 03 2021 How do I use variables (application version for example) from
- Andre Pany (7/10) Mar 03 2021 You can use command `dub describe` to get all information for a
- dog2002 (4/14) Mar 03 2021 Thank you for your answer, but I want to put the application
- Andre Pany (10/26) Mar 03 2021 Ok, now I understand. My approach for this is to specify in
- Steven Schveighoffer (8/10) Mar 03 2021 AFAIK, that's not passed directly to the application. And the version is...
How do I use variables (application version for example) from dub.json? Is it possible? For example, I want the application version to be printed.
Mar 03 2021
On Wednesday, 3 March 2021 at 12:50:16 UTC, dog2002 wrote:How do I use variables (application version for example) from dub.json? Is it possible? For example, I want the application version to be printed.You can use command `dub describe` to get all information for a dub project. It has some arguments to filter for specific information and on linux you can of course use jq to filter out any information from the json produced by `dub describe`. Kind regards Andre
Mar 03 2021
On Wednesday, 3 March 2021 at 15:05:16 UTC, Andre Pany wrote:On Wednesday, 3 March 2021 at 12:50:16 UTC, dog2002 wrote:Thank you for your answer, but I want to put the application version in variable in the application code automatically during compiling process.How do I use variables (application version for example) from dub.json? Is it possible? For example, I want the application version to be printed.You can use command `dub describe` to get all information for a dub project. It has some arguments to filter for specific information and on linux you can of course use jq to filter out any information from the json produced by `dub describe`. Kind regards Andre
Mar 03 2021
On Wednesday, 3 March 2021 at 15:46:12 UTC, dog2002 wrote:On Wednesday, 3 March 2021 at 15:05:16 UTC, Andre Pany wrote:Ok, now I understand. My approach for this is to specify in dub.json `preGenerateCommands` which calls a .cmd on windows and a .sh on posix. The scripts generate a d module and reads the dub package version from environment variable DUB_PACKAGE_VERSION and writes them into a enum. You could also have a look at dfmt or DScanner. They do s.th. similiar. Kind regards AndreOn Wednesday, 3 March 2021 at 12:50:16 UTC, dog2002 wrote:Thank you for your answer, but I want to put the application version in variable in the application code automatically during compiling process.How do I use variables (application version for example) from dub.json? Is it possible? For example, I want the application version to be printed.You can use command `dub describe` to get all information for a dub project. It has some arguments to filter for specific information and on linux you can of course use jq to filter out any information from the json produced by `dub describe`. Kind regards Andre
Mar 03 2021
On 3/3/21 7:50 AM, dog2002 wrote:How do I use variables (application version for example) from dub.json? Is it possible? For example, I want the application version to be printed.AFAIK, that's not passed directly to the application. And the version is not actually stored in the dub.json file (it's a tag on git). I think you would have to use git to get the information. If you want the versions of the dependencies, it's in the dub.selections.json file. It's probably possible to import the file and parse the json directly. -Steve
Mar 03 2021