Module: Docscribe::CLI::Init

Defined in:
lib/docscribe/cli/init.rb

Overview

Generate starter Docscribe configuration.

Constant Summary collapse

<<~TEXT
  Usage: docscribe init [options]

  Generate a starter docscribe.yml configuration file.

  Options:
TEXT

Class Method Summary collapse

Class Method Details

.run(argv) ⇒ Integer

Create or print a starter Docscribe configuration file.

Supported behaviors:

  • write ‘docscribe.yml` (default)

  • write to a custom path via ‘–config`

  • overwrite an existing file via ‘–force`

  • print the template to STDOUT via ‘–stdout`

Parameters:

  • argv (Array<String>)

    command-line arguments for ‘docscribe init`

Returns:

  • (Integer)

    process exit code



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/docscribe/cli/init.rb', line 29

def run(argv)
  opts = parse_init_options(argv)
  return 0 if opts[:help]

  yaml = Docscribe::Config.default_yaml

  if opts[:stdout]
    puts yaml
    return 0
  end

  write_init_config(opts, yaml)
end