Questions tagged [command-line-arguments]

Programming command line utilities that take parameters.

This tag should have questions relating to programming command-line utilities that take arguments.

A command line argument is a parameter passed to a command line program. For instance git status is the Git command line program with the parameter status. Git then acts accordingly to that parameter.

Command line arguments are used in command line programs from the Command Prompt on Windows, a shell on Unix and the Terminal program on Mac OS. These are not visual GUI programs, they are text based.

Learn more: Wikipedia Article Command Line

5018 questions
65
votes
2 answers

In Visual Studio Code, how to pass arguments in launch.json

In Visual Studio Code, in the launch.json file that launches the app I'm writing, how do I add command line arguments?
Jonathan Benn
  • 2,908
  • 4
  • 24
  • 28
65
votes
2 answers

How to make a short and long version of a required argument using Python Argparse?

I want to specify a required argument called inputdir but I also would like to have a shorthand version of it called i. I don't see a concise solution to do this without making both optional arguments and then doing my own check. Is there a…
user3621633
  • 1,681
  • 3
  • 32
  • 46
65
votes
7 answers

Handle spaces in argparse input

Using python and argparse, the user could input a file name with -d as the flag. parser.add_argument("-d", "--dmp", default=None) However, this failed when the path included spaces. E.g. -d C:\SMTHNG\Name with spaces\MORE\file.csv NOTE: the…
ofer.sheffer
  • 5,417
  • 7
  • 25
  • 26
64
votes
10 answers

Console app arguments, how arguments are passed to Main method

This would be question from c# beginner. When I create console application I get Main method with parameter args as array string. I do not understand how this method is called by system and how args are passed to the Main method. Maybe someone…
Tomas
  • 17,551
  • 43
  • 152
  • 257
61
votes
4 answers

Call another click command from a click command

I want to use some useful functions as commands. For that I am testing the click library. I defined my three original functions then decorated as click.command: import click import os, sys @click.command() @click.argument('content',…
kaligne
  • 3,098
  • 9
  • 34
  • 60
59
votes
3 answers

WPF Command Line Arguments, a smart way?

I'm looking for a way that I can parse command line arguments into my WPF application with just a way of reading the value of the argument that the user passed. As an example application.exe /setTime 5 is there a way for me to have some code where…
Sandeep Bansal
  • 6,280
  • 17
  • 84
  • 126
59
votes
9 answers

How can I use long options with the Bash getopts builtin?

I am trying to parse a -temp option with Bash getopts. I'm calling my script like this: ./myscript -temp /foo/bar/someFile Here is the code I'm using to parse the options. while getopts "temp:shots:o:" option; do case $option in temp)…
Hemang
  • 773
  • 2
  • 6
  • 12
58
votes
4 answers

Pass arguments to Python argparse within Docker container

I am embarking on my first attempt at utilizing a docker container. I have a python script that calls a couple API's and parses a file. The script took parameters for the URL of the server for the API, the API key, and the file path for the file…
Bring Coffee Bring Beer
  • 1,035
  • 3
  • 11
  • 19
55
votes
2 answers

Maximum length of command line argument that can be passed to SQL*Plus?

I am calling SQL*Plus from Linux C Shell: sqlplus username/password @file.sql var1 var2 var3 If I pass a string as var1, how long can this string be? Is it governed by the OS? In this case: Linux version 2.6.9-100.ELsmp…
Umber Ferrule
  • 3,358
  • 6
  • 35
  • 38
54
votes
5 answers

Parsing command line arguments in R scripts

Is there any convenient way to automatically parse command line arguments passed to R scripts? Something like perl's Getopt::Long?
David B
  • 29,258
  • 50
  • 133
  • 186
53
votes
4 answers

How to publish results using dotnet test command

I have a test project written in dotnet core. This need to publish the results in an XML or HTML format. Is there a way I can publish the results to a particular directory using the same command? --result-directory is not working for me
53
votes
1 answer

Restricting values of command line options

How do I restrict the values of the argparse options? In the below code sau option should only accept a number of 0 or 1 and bg should only allow an integer. How can I implement this? import os import sys, getopt import argparse def main (): …
user1934146
  • 2,905
  • 10
  • 25
  • 25
52
votes
7 answers

Use of -noverify when launching java apps

I have seen many apps that take instrument classes and take -javaagent as a param when loading also put a -noverify to the command line. The Java doc says that -noverify turns off class verification. However why would anyone want to turn off…
pdeva
  • 43,605
  • 46
  • 133
  • 171
51
votes
4 answers

Auto-complete command line arguments

In bash, executables such as mplayer and imagemagick's "convert" have a cool auto-complete functionality on their command line arguments. For instance, if I type mplayer in one of my video folders, then mplayer will list all media files…
Régis B.
  • 10,092
  • 6
  • 54
  • 90
49
votes
5 answers

How can I require my python script's argument to be a float in a range using argparse?

I'd like to use argparse on Python 2.7 to require that one of my script's parameters be between the range of 0.0 and 1.0. Does argparse.add_argument() support this?
Dolan Antenucci
  • 15,432
  • 17
  • 74
  • 100