Class: Dbdoc::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/dbdoc/cli.rb

Constant Summary collapse

COMMANDS =
{
  install: %(
    Generates all necessary config files and documentation folders.

    Run this command in an empty directory.
  ),
  query: %(
    Prints a query that you need to run in the database \
    you're going to document.

    Export the result of this query to the "schema.csv" file \
    and copy it over to the "schema" folder for processing.
  ),
  plan: %(
    Shows you what columns/tables/schemas are new and \
    going to be added/deleted from the documentation.
  ),
  apply: %(
    Generates boilerplate documentation for newly added \
    columns/tables/schemas.

    Drops documentation for columns/tables/schemas that \
    were deleted from the database.
  ),
  "confluence:upload": %(
    Uploads current documentation to Confluence: pages for \
    new tables/schemas will be added, pages for dropped tables/schemas \
    will be deleted from your Confluence space.
  ),
  "confluece:pages": %(
    Lists all pages in your dbdoc Confluence space \
    (created manually or via dbdoc).
  ),
  "confluence:clear": %(
    IMPORTANT This command will delete ALL pages from \
    the Confluence space (pages created via dbdoc AND pages that were added manually).
  ),
  todo: %(
    Shows you the documentation that needs to be written.
  )
}.freeze

Instance Method Summary collapse

Instance Method Details

#run(args = []) ⇒ Object

rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/dbdoc/cli.rb', line 52

def run(args = [])
  if args.first == "install"
    Dbdoc::FolderInitializer.new.init
  elsif args.first == "query"
    puts manager.query
  elsif args.first == "plan"
    plan = manager.plan

    puts "--> New columns:"
    plan[:new_columns].each do |column|
      puts column
    end

    puts "--> Columns to drop:"
    plan[:columns_to_drop].each do |column|
      puts column
    end
  elsif args.first == "apply"
    manager.apply
  elsif args.first == "confluence:upload"
    uploader.upload
  elsif args.first == "confluence:pages"
    uploader.print_space_pages
  elsif args.first == "confluence:clear"
    uploader.clear_confluence_space
  elsif args.first == "todo"
    manager.todo
  elsif args.first == "help"
    print_help
  elsif args.first == "version"
    puts Dbdoc::VERSION
  end

  0
end