Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Arguments and Options?

Tags:

I'm not really sure on what level this terminology exists, but in the php-framework Laravel there is a command-line-tool called Artisan that is being used for creating cronjobs. (aka commands) When you create a command. You can specify arguments AND options like this:

/**  * Get the console command arguments.  *  * @return array  */ protected function getArguments() {     return array(         array('example', InputArgument::REQUIRED, 'An example argument.'),     ); }  /**      * Get the console command options.      *      * @return array      */     protected function getOptions()     {         return array(             array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),         );     } 

What's the difference between the two?

like image 245
Himmators Avatar asked Jul 24 '13 14:07

Himmators


People also ask

What is difference between argument and option?

Argument 0 is (normally) the command name, argument 1, the first element following the command, and so on. These arguments are sometimes called positional parameters. An option is a documented1 type of argument modifying the behavior of a command, e.g. -l commonly means "long", -v verbose.

What is an option argument?

Option arguments are information needed by an option, as opposed to regular operand arguments. For example, the fgrep program's -f option means "use the contents of the following file as a list of strings to search for." See Figure 2.1.

What is difference between arguments and variables?

The values that are declared within a function when the function is called are known as an argument. The variables that are defined when the function is declared are known as parameters. These are used in function call statements to send value from the calling function to the receiving function.

What does argument mean in Linux?

An argument, also called a command line argument, is a file name or other data that is provided to a command in order for the command to use it as an input. A command is an instruction telling a computer to do something, such as execute (i.e., run) a program.


1 Answers

Take a look at the artisan migrate:make help:

Usage:  migrate:make [--bench[="..."]] [--create] [--package[="..."]] [--path[="..."]] [--table[="..."]] name  Arguments:  name                  The name of the migration  Options:  --bench               The workbench the migration belongs to.  --create              The table needs to be created.  --package             The package the migration belongs to.  --path                Where to store the migration.  --table               The table to migrate.  --help (-h)           Display this help message.  --quiet (-q)          Do not output any message.  --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug  --version (-V)        Display this application version.  --ansi                Force ANSI output.  --no-ansi             Disable ANSI output.  --no-interaction (-n) Do not ask any interactive question.  --env                 The environment the command should run under. 

Argument is something you usually need to provide at least one, in this case you need to provide the migration name or the command will raise an error.

Option is, obviously, optional, something that you use to modify the command behaviour.

like image 60
Antonio Carlos Ribeiro Avatar answered Oct 16 '22 12:10

Antonio Carlos Ribeiro