-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Description
Passing variables as environment variables is fine for configuration variables, but having used ain a bit, I feel that passing variables as arguments would be much more natural when the variable in question varies often. This applies both when scripting and on the command line.
Using a double hyphen to denote that the following arguments are variables might be a good way to do this. It would allow easy editing of parameters when calling the same endpoint a few times.
$ ain -e config.env base.ain specific_query.ain -- --id=2
push up arrow and change the id
$ ain -e config.env base.ain specific_query.ain -- --id=3
When scripting
NB: I'm using camelCase for my variables that I know change often
Before
#!/usr/bin/env bash
packageSearch=$1
#search for the package to find the id
packageId=$(searchTerm=$packageSearch ain package_service_template.ain search_package.ain | jq '.[] | .id')
#view simplified event history
id=$packageId ain keycafe_template.ain package_events.ain | jq '.[] | {eventName, user, dateCreated, location}'
After
#!/usr/bin/env bash
packageSearch=$1
#search for the package to find the id
packageId=$(ain package_service_template.ain search_package.ain -- --searchTerm=$packageSearch | jq '.[] | .id')
#view simplified event history
ain keycafe_template.ain package_events.ain -- --id=$packageId | jq '.[] | {eventName, user, dateCreated, location}'
Metadata
Metadata
Assignees
Labels
No labels