Подтвердить что ты не робот

Какая разница между аргументами и опциями?

Я не уверен, на каком уровне существует эта терминология, но в php-framework Laravel есть инструмент командной строки Artisan, который используется для создания cronjob. (aka commands) Когда вы создаете команду. Вы можете указать аргументы И параметры, подобные этому:

/**
 * 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),
        );
    }

Какая разница между двумя?

4b9b3361

Ответ 1

Взгляните на справку artisan migrate:make:

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.

Аргумент - это то, что вам обычно нужно предоставить, по крайней мере, одному, в этом случае вам нужно указать имя миграции или команда вызовет ошибку.

Опция, очевидно, необязательна, что-то, что вы используете для изменения поведения команды.