develop #3

Merged
glenux merged 35 commits from develop into master 2024-06-02 07:08:41 +00:00
4 changed files with 57 additions and 14 deletions
Showing only changes of commit 801e58ca27 - Show all commits

View file

@ -1,6 +1,6 @@
module DocMachine module DocMachine
class Launcher class Builder
def initialize(config) def initialize(config)
@basedir = config[:data_dir]? ? config[:data_dir] : Dir.current @basedir = config[:data_dir]? ? config[:data_dir] : Dir.current
@basehash = Digest::SHA256.hexdigest(@basedir)[0..6] @basehash = Digest::SHA256.hexdigest(@basedir)[0..6]
@ -120,5 +120,19 @@ module DocMachine
def docker_opts() def docker_opts()
end end
def self.add_options(opts)
opts.on("build", "Build content and produce deliverables") do
opts.banner = [
"Usage: #{PROGRAM_NAME} build [options]",
"",
"Main options:"
].join("\n")
opts.separator ""
opts.separator "Builder Options:"
opts.on("-t", "--test", "Test") { puts "Test" }
end
end
end end
end end

View file

@ -2,7 +2,9 @@ require "option_parser"
require "digest/sha256" require "digest/sha256"
require "colorize" require "colorize"
require "./launcher" require "./builder/builder.cr"
require "./scaffolder/scaffolder.cr"
require "./planner/planner.cr"
module DocMachine module DocMachine
class Cli class Cli
@ -13,7 +15,11 @@ module DocMachine
options = {} of Symbol => String options = {} of Symbol => String
parser = OptionParser.new do |opts| parser = OptionParser.new do |opts|
opts.banner = "Usage: script.cr [options]" opts.banner = [
"Usage: #{PROGRAM_NAME} [options]",
"",
"Main options:"
].join("\n")
opts.on("-d", "--data-dir DIR", "Content directory") do |dir| opts.on("-d", "--data-dir DIR", "Content directory") do |dir|
options[:data_dir] = dir options[:data_dir] = dir
@ -35,6 +41,12 @@ module DocMachine
puts opts puts opts
exit exit
end end
opts.separator ""
opts.separator "Commands:"
DocMachine::Builder.add_options(opts)
DocMachine::Scaffolder.add_options(opts)
DocMachine::Planner.add_options(opts)
end end
parser.parse(ARGV) parser.parse(ARGV)
@ -47,20 +59,14 @@ module DocMachine
docker_image = "glenux/docmachine:latest" docker_image = "glenux/docmachine:latest"
if options[:help]? if options[:help]?
puts "Usage: script.cr [options]" puts parser.to_s
puts ""
puts "-d, --data-dir DIR Content directory"
puts "-a, --action ACTION Action (watch, build, shell, etc.)"
puts "-t, --tty Enable TTY mode (needed for shell)"
puts "-v, --verbose Enable verbosity"
puts "-h, --help Show this help"
exit exit
end end
launcher = DocMachine::Launcher.new(options) builder = DocMachine::Builder.new(options)
launcher.prepare builder.prepare
launcher.start builder.start
launcher.wait builder.wait
end end
end end
end end

11
src/planner/planner.cr Normal file
View file

@ -0,0 +1,11 @@
module DocMachine
class Planner
def self.add_options(opts)
opts.on("content", "Generate content and structure") do
opts.banner = "Usage: #{PROGRAM_NAME} plan [options]"
opts.on("-t", "--test", "Test") { puts "Test" }
end
end
end
end

View file

@ -0,0 +1,12 @@
module DocMachine
class Scaffolder
def self.add_options(opts)
opts.on("scaffold", "Scaffold directory") do
opts.banner = "Usage: #{PROGRAM_NAME} scaffold [options]"
opts.on("-t", "--test", "Test") { puts "Test" }
end
end
end
end