Class: Uniword::PageCLI

Inherits:
Thor
  • Object
show all
Includes:
CLIHelpers
Defined in:
lib/uniword/cli/page_cli.rb

Overview

Page subcommands for Uniword CLI.

Uniform page setup across a document — the CLI equivalent of Word's Layout dialog (size, orientation, margins).

Instance Method Summary collapse

Methods included from CLIHelpers

included

Instance Method Details

#setup(input_path, output_path) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/uniword/cli/page_cli.rb', line 38

def setup(input_path, output_path)
  opts = setup_options
  unless opts
    say "Error: specify at least one of --size, --orientation, " \
        "--margins, --margin-top/right/bottom/left", :red
    exit 1
  end

  say "Loading document #{input_path}...", :green if options[:verbose]

  sections = apply_setup(input_path, output_path, opts)
  say "Page setup applied to #{sections} section(s) in #{output_path}",
      :green
rescue Uniword::Error => e
  handle_error(e)
rescue StandardError => e
  handle_error(e, verbose: options[:verbose])
end