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
22
votes
7 answers

Handling command line flags in C/C++

I am looking for a very simple explanation/tutorial on what flags are. I understand that flags work indicate a command what to do. For example: rm -Rf test I know that the rm command will remove the test folder and that the -Rf flags will force the…
Fabio Gomez
  • 687
  • 2
  • 7
  • 13
22
votes
4 answers

Open Chrome from terminal with developer console open

I can run Google Chrome from the command line using $ google-chrome, but what flag can I pass to open it with developer console already open, preferably open to the console tab? I checked the man page for google-chrome but it states that Google…
Maros
  • 1,825
  • 4
  • 25
  • 56
21
votes
5 answers

Powershell Execute remote exe with command line arguments on remote computer

I've searched all over and tried different variations of commands, but I am still not there yet. My goal is to run an exe that already resides on a remote machine and pass in command line arguments. I've tried invoke-command, but I can't seem to…
gregs
  • 605
  • 2
  • 7
  • 16
21
votes
3 answers

Emacs shell scripts - how to put initial options into the script?

Inspired by Stack Overflow question Idomatic batch processing of text in Emacs? I tried out an Emacs shell script with the following headline: #!/usr/bin/emacs --script I put some Emacs Lisp code in it, and saved it as textfile rcat. Since the…
Thorsten
  • 3,451
  • 3
  • 20
  • 25
21
votes
1 answer

Unquoted tokens in argument mode involving variable references and subexpressions: why are they sometimes split into multiple arguments?

Note: A summary of this question has since been posted at the PowerShell GitHub repository, since superseded by this more comprehensive issue. Arguments passed to a command in PowerShell are parsed in argument mode (as opposed to expression mode -…
mklement0
  • 382,024
  • 64
  • 607
  • 775
21
votes
2 answers

Is there a way to make git auto generate a version number file for a --version option?

I have a project that is moving out of the alpha phase and that I'm ready to start releasing regularly. I know GitHub has a 'magic' release button but I generally don't like 'magic' features that I don't know exactly what they…
os x nerd
  • 897
  • 1
  • 10
  • 18
21
votes
2 answers

Grunt - Command Line Arguments, not working

I am using command line options in my grunt script: http://kurst.co.uk/transfer/Gruntfile.js However the command grunt --vers:0.0.1 always returns 'undefined' when I try to get the option: var version = grunt.option('vers') || ''; Can you help me…
user2386872
  • 345
  • 1
  • 2
  • 15
21
votes
1 answer

C# Process Start needs Arguments with double quotes - they disappear

I'm trying to run a cmd line application from c# using Process.Start(ProcessStartInfo); The problem is, the cmd line application is a matlab standalone .exe and has optional arguments meaning that you pass them on the cmd line as such: app.exe…
poncho
  • 1,100
  • 2
  • 15
  • 38
21
votes
3 answers

Why are getArgs and getProgName IO actions?

I'm a complete newbie currently trying to learn Haskell with "Learn You a Haskell for Great Good". I've reach the section explaining how to work with command line arguments, and something is bugging me. From my understanding (and haskell.org's…
icecrime
  • 74,451
  • 13
  • 99
  • 111
21
votes
3 answers

Print help for both normal and positional args with boost::program_options

When you use Boost library program_options it is very easy to print help for your program: boost::program_options::variables_map options; boost::program_options::options_description optionsDesc; boost::program_options::positional_options_description…
nuoritoveri
  • 2,494
  • 1
  • 24
  • 28
20
votes
3 answers

How can I pass main's *argv[] to a function?

I have a program that can accept command-line arguments and I want to access the arguments, entered by the user, from a function. How can I pass the *argv[], from int main( int argc, char *argv[]) to that function ? I'm kind of new to the concept of…
Eternal_Light
  • 676
  • 1
  • 7
  • 21
20
votes
4 answers

How to get access to command-line arguments in Nim?

How can I access command line arguments in Nim? The documentation shows only how to run the compiled Nim code with command line arguments nim compile --run greetings.nim arg1 arg2 but I didn't find how to use their values in code.
Lucian Bredean
  • 803
  • 1
  • 10
  • 21
20
votes
2 answers

Retrieve the command line arguments of the Python interpreter

Inspired by another question here, I would like to retrieve the Python interpreter's full command line in a portable way. That is, I want to get the original argv of the interpreter, not the sys.argv which excludes options to the interpreter itself…
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
20
votes
4 answers

how can I force division to be floating point in Go?

I have the following code snippet: package main import("fmt";"flag") func main() { var a = flag.Int("a",0,"divident") var b = flag.Int("b",1,"divisor") flag.Parse() fmt.Printf("%f",*a / *b ) } For -a 3 and -b 2 command line…
Croo
  • 1,301
  • 2
  • 13
  • 32
20
votes
2 answers

python command line arguments in main, skip script name

This is my script def main(argv): if len(sys.argv)>1: for x in sys.argv: build(x) if __name__ == "__main__": main(sys.argv) so from the command line I write python myscript.py commandlineargument I want it to skip…
CQM
  • 42,592
  • 75
  • 224
  • 366