Apache Commons CLI named positional parameters in autoUsage - apache-commons-cli

It is possible to retrieve positional parameters in Apache Commons CLI. Is it possible to name them for the usage statement? To be concrete, the Apache Commons CLI documentation gives an ls Example:
Usage: ls [OPTION]... [FILE]...
How could I use a HelpFormatter to output "[FILE]..." when calling HelpFormatter.printHelp(..., autoUsage = true)? These are the values returned by CommandLine.getArgs(). I know how to name Option arguments in a usage message but not how to name such positional arguments.

Related

Powershell: Have working Aliases for longer commands with parameters

I am trying to write some PowerShell aliases in my profile.ps1 file. The problem is that I can not get commands with a variable number of parameters to work properly.
For example, I want to have an alias that links "kg" to "kubectl get", which is followed by a resource and sometimes an option. So "kg pods -A" and "kg pod" should both work afterwords.
According to this post, I need to define a function that can be seen below, my problem is that it ignores all arguments after the first. So "kg pods -A" returns the result of "kg pods".
This post explains how to pass multiple arguments to a function, up it does not work for some reason.
(I am using Powershell in Cmder if this is relevant).
Could it be that the "-" causes an issue?
The relevant part of the "profile.ps1":
Function get ($restOfLine, $restOfLine2) { kubectl get $restOfLine $restOfLine2}
Set-Alias kg get
As soon as you explicitly declare parameters in a function, PowerShell will attempt to bind input arguments to those parameters, by parsing the command invocation expression and treating any sequence starting with - as a parameter name.
Remove the parameters and pass $args directly to avoid this interference:
function get { kubectl get #args }
Set-Alias kg get
kg post -A will now pass post and -A to kubectl as-is

Is there a way to configure pytest_plugins from a pytest.ini file?

I may have missed this detail but I'm trying to see if I can control the set of plugins made available through the ini configuration itself.
I did not find that item enumerated in any of the configurable command-line options nor in any of the documentation around the pytest_plugins global.
The goal is to reuse a given test module with different fixture implementations.
#hoefling is absolutely right, there is actually a pytest command line argument that can specify plugins to be used, which along with the addopts ini configuration can be used to select a set of plugin files, one per -p command.
As an example the following ini file selects three separate plugins, the plugins specified later in the list take precedence over those that came earlier.
projX.ini
addopts =
-p projX.plugins.plugin_1
-p projX.plugins.plugin_2
-p projY.plugins.plugin_1
We can then invoke this combination on a test module with a command like
python -m pytest projX -c projX.ini
A full experiment is detailed here in this repository
https://github.com/jxramos/pytest_behavior/tree/main/ini_plugin_selection

How to Pass argument to Oozie

My use case is the following, I am building an Oozie Pipeline and i need to pass it an argument.
Indeed my spark job must receive a string date as an argument and it would be great to pass the argument to the Oozie Workflow in order to use it in the Spark Submit. Anyone got any idea ? I didn't find the answer on Google
Thanks
Create workflow.xml that references some variable inputDate
Create
file job.properties that defines default value for inputDate
Run
your job using CLI, overriding default value when is needed:
oozie job -run -config job.properties -DinputDate=2017-08-19

How to pass query parameters value as parameter from CMD using talend ESB6.3.1

I'm using Talend Open Studio for ESB ver.6.3.1 and created the jobs which is used to pull the data from ALM to MongoDB.In that i used tRESTClient with query parameter(date) for pulling data from ALM & tMongoDBOutput for inserting ALM data. After that i've build the job & imported into eclipse as a java project. I tried to run the program with option of 'Run as Java Application'.It is working fine.
The above job i gave query parameter value directly like 'tRESTClient --> Basic settings --> Query parameters --> name = "query" & value = "{last-modified[>=(2017-04-19 13:02:15)]}" ', so this job will pull the records based on the query parameters value.
Now i generated the eclipse talend job as a runnable jar file & trying to pass query parameter value from CMD as a parameter value.
How to pass query parameters value as parameter from CMD?
In windows command promote you can write the following command form.
for example if you have a jar file named test.jar and you have two parameters name & query, then you can pass the command as
javaw -jar test.jar -n 'name' -q 'your query'
Then you can handle these two parameters i.e name and query in your main method.

I want to use the output of `gcloud` in a script, but the format changes. What should I do?

I’m using the command gcloud compute instances list in a script, but I’m worried that the exact output format isn’t static. What should I do?
You should use the --format flag, available for most gcloud commands.
For instance, if you’d like to get the exact same output as the current (as of the time of writing of this answer) format, you can run:
$ gcloud compute instances list --format="table(
name,
zone.basename(),
machineType.basename(),
scheduling.preemptible.yesno(yes=true, no=''),
networkInterfaces[0].networkIP:label=INTERNAL_IP,
networkInterfaces[0].accessConfigs[0].natIP:label=EXTERNAL_IP,
status
)"
The output of this command will not change between releases, even if the default output of the command does (unless the resource being formatted changes; this should be rare).1 Showing the default format for resources in commands is a work in progress.2
You can also specify a format like YAML or JSON for machine-readable output:
$ gcloud compute instances list --format=yaml
$ gcloud compute instances list --format=json
Note that this output contains much more information than is present in the default output for this command; this is the information you have to work with when constructing a custom format.
CSV is another format option. Like table, it requires a projection–a specification for how to print each row.3
$ gcloud compute instances list --format="csv(name,zone,status)"
name,zone,status
example-instance,us-central1-f,RUNNING
...
For more information on the formatting capabilities of gcloud, see the output of gcloud topic formats and gcloud topic projections.
You can see all possible fields by running gcloud compute instances list --format=flattened.
For some commands, like gcloud beta test android locales list, you can pass the --verbosity=info flag and look for INFO: Display format.
This is because CSV data cannot be nested like JSON or YAML, and the data structures being printed may be nested.