Class: Uniword::StylesCLI

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

Overview

Styles subcommands for Uniword CLI.

Inspect the styles inside a document — the CLI equivalent of Word's Styles pane.

Instance Method Summary collapse

Methods included from CLIHelpers

included

Instance Method Details

#list(path) ⇒ Object



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

def list(path)
  styles = gather_styles(path)
  if styles.empty?
    say "No styles found.", :yellow
    return
  end

  say "Styles in #{File.basename(path)} (#{styles.size}):", :green
  styles.each { |style| print_style(style) }
rescue Uniword::Error => e
  handle_error(e)
rescue StandardError => e
  handle_error(e, verbose: options[:verbose])
end

#remove(input_path, output_path) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/uniword/cli/styles_cli.rb', line 61

def remove(input_path, output_path)
  doc = load_document(input_path)
  removed = run_removal(doc)
  report_removal(doc, removed, output_path)
rescue Uniword::Error => e
  handle_error(e)
rescue StandardError => e
  handle_error(e, verbose: options[:verbose])
end

#rename(input_path, output_path) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/uniword/cli/styles_cli.rb', line 87

def rename(input_path, output_path)
  identifier = rename_identifier
  doc = load_document(input_path)
  perform_rename(doc, identifier, output_path)
rescue Uniword::Error, StandardError => e
  handle_error(e, verbose: options[:verbose])
end