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
29
votes
2 answers

Why do I need "sys.argv" to start a QApplication in PyQt?

I try to understand what PyQt does. And one of the first things I didn't, was: QApplication(sys.argv) Why do I have to give QApplication this argument? I know what sys.argv does. But in my Scripts I wouldn't need it.
Sir2B
  • 1,029
  • 1
  • 10
  • 17
28
votes
4 answers

Passing a List to Python From Command Line

I would like to make my python script run from the command line when supplies with some arguments. However, one of the arguments should be a list of options specific to one segment of the script. Would string parsing be the only way to do this by…
Sam
  • 2,398
  • 4
  • 25
  • 37
28
votes
3 answers

How can I pass command line arguments to a standalone MATLAB executable running on Linux/Unix?

How can I pass command line arguments to a standalone MATLAB executable running on Linux/UNIX? I need to compile my MATLAB script as a standalone file that can be run on a machine without MATLAB present. It needs to be able to work in a way similar…
27
votes
4 answers

How do I format positional argument help using Python's optparse?

As mentioned in the docs the optparse.OptionParser uses an IndentedHelpFormatter to output the formatted option help, for which which I found some API documentation. I want to display a similarly formatted help text for the required, positional…
cdleary
  • 69,512
  • 53
  • 163
  • 191
27
votes
3 answers

Launch Program with Parameters

How do I write a very simple program that uses the command line to navigate to a program in the user's Program Files directory, then launches the .exe with a parameter? For example: "C:\etc\Program Files\ProgramFolder\Program.exe…
mark
  • 371
  • 2
  • 6
  • 10
27
votes
1 answer

How to parse an optional flag as a Maybe value?

I'm trying to use optparse-applicative to parse a Maybe String but I can't find anywhere how to deal with Maybe. The only thing I found is to add a default value but I really need a Nothing if user didn't supply an option instead of "". Is there any…
mb14
  • 22,276
  • 7
  • 60
  • 102
27
votes
1 answer

GCC define function-like macros using -D argument

Problem I am trying to remove __attribute__ from my C code before I send it into a parser. Is there a way to define function-like macros using the -D argument? Solution using header file #define __attribute__(x) Attempted Solution gcc -E…
Stefan Bossbaly
  • 6,682
  • 9
  • 53
  • 82
27
votes
5 answers

Why main() in C++ is not overloaded to use std::string?

I was trying to create a program that takes arguments by command line, using main() function arguments. As a (basic) C++ programmer (even if I know quite well pointers and array in C-style) I hardly ever used char* strings and C-arrays. I spent some…
user1434698
27
votes
5 answers

How to run Java program in command prompt

I created a Java project to call a Web service. It has one Main java file and another class file. I have used some jar files for HTTP client. In Eclipse it runs fine. I need to run the Java program in command prompt by passing some arguments. In…
Vignesh
  • 2,295
  • 7
  • 33
  • 41
27
votes
2 answers

OS X: strange -psn command line parameter when launched from Finder

Our OS X Java application which is launched by a shell script inside the MyApp.app bundle gets a strange command line parameter -psn_0_989382 when launched from the Finder, but not when launched directly from the Terminal. Where can I find…
Mot
  • 28,248
  • 23
  • 84
  • 121
26
votes
4 answers

Concise command line for subversion copy (branch)

All examples of svn branching I have seen so far look like this svn cp -m 'Making test branch' svn://svnrepo/hellosite svn://svnrepo/hellosite2 So in order to branch I need to specify full URL of remote repository every time. But: Working copy is…
Petr Gladkikh
  • 1,906
  • 2
  • 18
  • 31
26
votes
1 answer

How to parse command line output from c#?

I want to execute an application(command line application) from the C#... and I want after executing this application and providing the input to it, I want to parse the output that will result it. Since, it will output many things, and I want to…
Q8Y
  • 3,801
  • 12
  • 39
  • 38
26
votes
1 answer

How to pass command line arguments?

I am not getting the desired output for this program: from sys import argv script, first, second, third = argv print ("The script is called:", script) print ("Your first variable is:", first) print ("Your second variable is:", second) print ("Your…
InquisitiveSu
  • 297
  • 1
  • 3
  • 4
26
votes
3 answers

flag package in Go - do I have to always set default value?

Is it possible not to set default value in flag package in Go? For example, in flag package you can write out the following line: filename := flag.String("file", "test.csv", "Filename to cope with") In the above code, I don't want to necessarily…
Blaszard
  • 30,954
  • 51
  • 153
  • 233
26
votes
5 answers

Sort argparse help alphabetically

I am using Python's (2.7) argparse facility and would like to automatically sort the help it produces alphabetically by option. By default help entries are sorted in the order they are added*, as in: p = argparse.ArgumentParser(description='Load…
Bryan P
  • 5,900
  • 5
  • 34
  • 49