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
25
votes
5 answers

Python command line parameters

I am just starting with python so I am struggling with a quite simple example. Basically I want pass the name of an executable plus its input via the command line arguments, e.g.: python myprogram refprogram.exe refinput.txt That means when…
Patrick
  • 989
  • 3
  • 16
  • 23
25
votes
1 answer

Cocoa: Pass arguments to NSApplicationDelegate

I have created the simple Cocoa application (Mac OS X 10.6) and there have appeared the entry point: int main(int argc, char *argv[]) { return NSApplicationMain(argc, (const char **) argv); } and AppDelegate dummy: -…
user663896
25
votes
7 answers

how to take integers as command line arguments?

I've read a getopt() example but it doesn't show how to accept integers as argument options, like cvalue would be in the code from the example: #include #include #include #include int main (int argc,…
Andrew
  • 1,081
  • 1
  • 8
  • 19
25
votes
4 answers

Arguments passed into for loop in bash script

I am trying to pass the argument as max limit for the for loop like this: #!/bin/bash for i in {1..$1} do echo $i done This however returns {1..2} when called with argument 2, instead of executing the script and giving me 1 2
Milo Wielondek
  • 4,164
  • 3
  • 33
  • 45
25
votes
5 answers

What is meaning of -vvv option in cURL request

According to cURL documentation http://curl.haxx.se/docs/manpage.html -v, --verbose Makes the fetching more verbose/talkative. But I came across curl -vvv -u name@foo.com:password http://www.example.com What is the difference between -v and…
pbaranski
  • 22,778
  • 19
  • 100
  • 117
25
votes
5 answers

Is it possible to pass in command line variables to a bitbake build?

I have an OpenEmbedded environment using bitbake to do some builds. I wanted to get something "interactive" going on where bitbake would pause and ask for input then continue with the build but I've found out that's not possible. Since I can't do…
Mike
  • 47,263
  • 29
  • 113
  • 177
24
votes
2 answers

What is the meaning of the -XX:NewRatio and -XX:OldSize JVM flags?

I am starting my java app with the following command line : java -XX:+PrintCommandLineFlags -verbose:gc -XX:+PrintGCDetails \ -XX:+UseConcMarkSweepGC -jar start.jar The JVM enables the following options: -XX:MaxNewSize=87244800…
24
votes
7 answers

How to read in numbers as command arguments?

How can make it so the program reads any two integers input before the program is run? I want the output to look like this, with x and y being any variables typed in (I am using Cygwin): $ ./a x y (product of x and y) (sum of x and y) I used int…
Kaity
  • 337
  • 1
  • 5
  • 12
24
votes
3 answers

Defining Independent FlagSets in GoLang

The Go documentation (http://golang.org/pkg/flag/) says: The FlagSet type allows one to define independent sets of flags, such as to implement subcommands in a command-line interface. I need this functionality but I can't figure out how to…
chowey
  • 9,138
  • 6
  • 54
  • 84
24
votes
1 answer

Python argparse required=True but --version functionality?

In all my scripts I use the standard flags --help and --version, however I cannot seem to figure out how to make a --version with parser.add_argument(..., required=True). import sys, os, argparse parser = argparse.ArgumentParser(description='How to…
Bob Tanner
  • 250
  • 1
  • 2
  • 5
24
votes
2 answers

What order of reading configuration values?

For the python program I am writing I would like to give the opportunity of configuring it in three different ways. Environment variables, configuration files and command line arguments. Logically I think command line arguments should always have…
23
votes
3 answers

How to implement --version using python click?

I want to implement mycommand --version using python click. I have something like this working but it feels kinda clunky. @click.group(invoke_without_command=True, no_args_is_help=True) @click.pass_context @click.option('--version', 'version') def…
wonton
  • 7,568
  • 9
  • 56
  • 93
23
votes
2 answers

How to test the passing of arguments in Golang?

package main import ( "flag" "fmt" ) func main() { passArguments() } func passArguments() string { username := flag.String("user", "root", "Username for this server") flag.Parse() fmt.Printf("Your username is %q.",…
030
  • 10,842
  • 12
  • 78
  • 123
23
votes
3 answers

Python - Difference between docopt and argparse

I have to write a command-line interface and I've seen I can use docopt and argparse. I would like to know what are the main differences between the two so that I can make an enlightened choice. Please stick to the facts. I don't want Wow. docopt.…
baldurmen
  • 669
  • 2
  • 7
  • 15
22
votes
1 answer

NDesk.Options: how to register required parameters correctly?

I am trying to utilize the OptionSet class in the following way: string resultsFileName = null; bool isHelp = false; var p = new OptionSet() { { "r=|resultsFile=", "The file with the results", v => { resultsFileName = v; } } {…
BreakPhreak
  • 10,940
  • 26
  • 72
  • 108