require "option_parser" require "digest/sha256" require "colorize" require "./config" require "./build/cli" require "./build/run" require "./scaffold/cli" require "./scaffold/run" require "./plan/cli" require "./plan/run" require "./write/cli" require "./write/run" module DocMachine class Cli def initialize end def start(args) config = Config.new commands = [] of Proc(Nil) parser = OptionParser.new do |opts| opts.banner = [ "Usage: #{PROGRAM_NAME} [options]", "", "Main options:" ].join("\n") opts.on("-v", "--verbose", "Enable verbosity") do |verbose| config.verbose = true end opts.on("-h", "--help", "Show this help") do puts opts exit end opts.separator "" opts.separator "Commands:" DocMachine::Scaffold::Cli.add_options(opts, args, config, commands) DocMachine::Plan::Cli.add_options(opts, args, config, commands) DocMachine::Write::Cli.add_options(opts, args, config, commands) DocMachine::Build::Cli.add_options(opts, args, config, commands) end parser.parse(args) puts commands if commands.size > 0 commands.each do |command| # puts "== Running #{command}" command.call() end else puts parser.to_s STDOUT.puts "" STDERR.puts "ERROR: no command defined" end end end end