Initializes the CLI environment.
182005
def cli(ctx):
    """"""
    dir_path = os.path.join(os.path.expanduser('~'), '.keep')
    if os.path.exists(dir_path):
        if click.confirm('[CRITICAL] Remove everything inside ~/.keep ?', abort=True):
            shutil.rmtree(dir_path)
    utils.first_time_use(ctx)
951002
public void initialize() {
        val pair = buildLoggerContext(environment, resourceLoader);
        pair.ifPresent(it -> {
            this.logConfigurationFile = it.getKey();
            this.loggerContext = it.getValue();
        });
    }
1327532
def init(name, runtime):
    """"""
    runtime = click.unstyle(runtime)

    stdout.write(
        style.format_command(
            'Initializing',
            '%s %s %s' % (name, style.gray('@'), style.green(runtime))
        )
    )

    config = Config(os.getcwd())
    config.set('runtime', runtime)
    config.save()

    generate.main(['init', name], standalone_mode=False)
    run.main(['python', 'manage.py', 'migrate'])
1017032
def init_app(self, app):
        """"""
        app.cli.add_command(upgrader_cmd)
        app.extensions['invenio-upgrader'] = self
279337
public function init()
    {
        parent::init();

        $parser         = new Parser();
        $yaml           = file_get_contents(PHPCI_CONFIG_FILE);
        $this->settings = $parser->parse($yaml);
    }
785749
static function init() {

		switch( PHP_SAPI ) {
		// Ideally we want to be runnning as CLI
		case 'cli':
			break;
		// Special conditions to ensure CGI runs as CLI
		case 'cgi':
			// Ensure resource constants are defined
			if( ! defined('STDERR') ){
				define( 'STDERR', fopen('php://stderr', 'w') );
			}
			if( ! defined('STDOUT') ){
				define( 'STDOUT', fopen('php://stdout', 'w') );
			}
			break;
		default:
			echo "Command line only\n";
			exit(1);
		}
		
		// Default error logger function
		PLUG::set_error_logger( array(__CLASS__,'format_logline') );
		
		// parse command line arguments from argv global
		global $argv, $argc;
		// first cli arg is always current script. second arg will be script arg passed to shell wrapper
		for( $i = 1; $i < $argc; $i++ ){
			$arg = $argv[ $i ];
			
			// Each command line argument may take following forms:
			//  1. "Any single argument", no point parsing this unless it follows #2 below
			//  2. "-aBCD", one or more switches, parse into 'a'=>true, 'B'=>true, and so on
			//  3. "-a value", flag used with following value, parsed to 'a'=>'value'
			//  4. "--longoption", GNU style long option, parse into 'longoption'=>true
			//  5. "--longoption=value", as above, but parse into 'longoption'=>'value'
			//  6."any variable name = any value" 
			
			$pair = explode( '=', $arg, 2 );
			if( isset($pair[1]) ){
				$name = trim( $pair[0] );
				if( strpos($name,'--') === 0 ){
					// #5. trimming "--" from option, tough luck if you only used one "-"
					$name = trim( $name, '-' );
				}
				// else is #6, any pair
				$name and self::$args[$name] = trim( $pair[1] );
			}
			
			else if( strpos($arg,'--') === 0 ){
				// #4. long option, no value
				$name = trim( $arg, "-\n\r\t " );
				$name and self::$args[ $name ] = true;
			}
			
			else if( $arg && $arg{0} === '-' ){
				$flags = preg_split('//', trim($arg,"-\n\r\t "), -1, PREG_SPLIT_NO_EMPTY );
				foreach( $flags as $flag ){
					self::$args[ $flag ] = true;
				}
				// leave $flag set incase a value follows.
				continue;
			}

			// else is a standard argument. use as value only if it follows a flag, e.g "-a apple"
			else if( isset($flag) ){
				self::$args[ $flag ] = trim( $arg );
			}

			// dispose of last flag
			unset( $flag );
			// next arg 
		}
	}
748686
def init():
    """"""
    default_config_path = path.join(
        (os.environ.get('TLDR_CONFIG_DIR') or path.expanduser('~')),
        '.tldrrc')
    if path.exists(default_config_path):
        click.echo("There is already a config file exists, "
                   "skip initializing it.")
    else:
        repo_path = click.prompt("Input the tldr repo path(absolute path)")
        if not path.exists(repo_path):
            sys.exit("Repo path not exist, clone it first.")

        platform = click.prompt("Input your platform(linux, osx or sunos)")
        if platform not in ['linux', 'osx', 'sunos']:
            sys.exit("Platform should be in linux, osx or sunos.")

        colors = {
            "description": "blue",
            "usage": "green",
            "command": "cyan"
        }

        config = {
            "repo_directory": repo_path,
            "colors": colors,
            "platform": platform
        }
        with open(default_config_path, 'w') as f:
            f.write(yaml.safe_dump(config, default_flow_style=False))

        click.echo("Initializing the config file at {0}".format(
            default_config_path))
882227
private void initExecutables() {
        if (StringUtils.isBlank(cmdMvn.getExecutable())) {
            if (StringUtils.isBlank(mvnExecutable)) {
                mvnExecutable = "mvn";
            }
            cmdMvn.setExecutable(mvnExecutable);
        }
        if (StringUtils.isBlank(cmdGit.getExecutable())) {
            if (StringUtils.isBlank(gitExecutable)) {
                gitExecutable = "git";
            }
            cmdGit.setExecutable(gitExecutable);
        }
    }
142857
def init(*, output_dir=FS_DEFAULT_OUTPUT_DIR, dry_run=False, **kwargs):
    
    # Output directory
    global _output_dir
    _output_dir = output_dir

    # Dry run mode
    global _dry_run
    _dry_run = dry_run

    # Type checks
    utils.chkstr(_output_dir, 'output_dir')

    # log the thing
    log.msg("Output directory will be: {output_dir}"
            .format(output_dir=_output_dir))

    # Create output directory if it does not exist
    if not os.path.exists(_output_dir):
        log.msg_warn("Output path '{out_dir}' does not exist, creating it ..."
                     .format(out_dir=_output_dir))
        if not _dry_run:
            # create the actual root output directory
            os.makedirs(_output_dir)
            # set folder permissions to 0770
            os.chmod(_output_dir, stat.S_IRWXU | stat.S_IRWXG)
356991
def init(self, args=None):
        """"""
        from .logs import exception

        self._setup_user_dir()
        self._init_settings_file()

        try:
            self.update(self._settings_from_file())
        except Exception:
            exception("Can't load settings from file", sys.exc_info())

        try:
            self.update(self._settings_from_env())
        except Exception:
            exception("Can't load settings from env", sys.exc_info())

        self.update(self._settings_from_args(args))
1320252
private function cliIO()
    {
        $services = [
            'Cli\Input'  => 'input',
            'Cli\Output' => 'output',
        ];

        foreach ($services as $className => $classOffset) {
            $this->services->load($className, $classOffset);
        }
    }
58449
protected function initEnvironment()
    {
        mb_internal_encoding('UTF-8');

        if (is_file($this->getFullEnvFilePath())) {
            $env = new DotEnv($this->basePath, $this->getEnvFile(), true);
            $env->load();
        }
    }
75240
public function init()
    {
        $this->addConsoleCommands();
        $this->getConsole()->add(new WorkerCommand($this));
        $this->getConsole()->add($this['init_command']);
        $this->getConsole()->add(new SshCommand($this));
        $this->getConsole()->add(new RunCommand($this));
        $this->getConsole()->add(new DebugCommand($this));
        $this->getConsole()->add(new AutocompleteCommand());
        $this->getConsole()->afterRun([$this, 'collectAnonymousStats']);
    }
1288582
protected function init() {
    if ($this->getConfig()->get('drush.bin')) {
      $this->executable = str_replace(' ', '\\ ', $this->getConfig()->get('drush.bin'));
    }
    else {
      $this->executable = 'drush';
    }

    if (!isset($this->dir)) {
      $this->dir($this->getConfig()->get('drush.dir'));
    }
    if (!isset($this->uri)) {
      $this->uri = $this->getConfig()->get('drush.uri');
    }
    if (!isset($this->alias)) {
      $this->alias($this->getConfig()->get('drush.alias'));
    }
    if (!isset($this->interactive)) {
      $this->interactive(FALSE);
    }
    if (!isset($this->ansi)) {
      $this->ansi($this->getConfig()->get('drush.ansi'));
    }

    $this->defaultsInitialized = TRUE;
  }
843612
def init():
    
    if "_" not in builtins.__dict__:  # avoid installing lang two times
        os.environ["LANGUAGE"] = inginious.input.get_lang()
        if inginious.DEBUG:
            gettext.install("messages", get_lang_dir_path())
        else:
            gettext.install("messages", get_lang_dir_path())
952229
private function initCommands()
	{
		if ($this->initialised)
		{
			return;
		}

		$this->initialised = true;

		foreach ($this->getDefaultCommands() as $command)
		{
			$this->addCommand($command);
		}
	}
863006
public function initialize()
    {
        if ($this->app->config('bono.cli')) {
            $app = $this->app;

            $this->app->container->singleton(
                'environment',
                function () {
                    return \Bono\CLI\Environment::getInstance();
                }
            );

            $this->app->notFound(
                function () use ($app) {
                    $argv = $GLOBALS['argv'];
                    $app->log->error('Command not found');
                    exit(255);
                }
            );

            $this->app->error(
                function ($err) use ($app) {
                    $app->log->error('');
                    $app->log->error('Error :'. $err->getMessage());
                    $app->log->error('File  :'. $err->getFile().':'.$err->getLine());
                    $app->log->error('');
                    $app->log->error($err->getTraceAsString());
                    $app->log->error('');
                    $app->log->error('Done with errors');
                    exit(1);
                }
            );

            $commands = $this->app->config('bonocli.commands');
            if ($commands) {
                foreach ($commands as $commandClass) {
                    $command = new $commandClass();
                    $command->initialize($this->app);
                }
            }
        }
    }