Module: Docscribe::CLI::Init

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

Overview

Generate starter Docscribe configuration.

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



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/docscribe/cli/init.rb', line 21

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