Skip to content

Commit

Permalink
Expose CLI inputs as flags
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Jul 10, 2024
1 parent 424b663 commit ba102a8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ This will generate a project folder with your project in it, and a markdown READ
- Configure RunDOC
- [rundoc.configure](#configure)
- Import and compose documents
- [rundoc.depend_on](#compose-multiple-rundoc-documents)
- [rundoc.require](#compose-multiple-rundoc-documents)

## RunDOC Syntax
Expand Down
38 changes: 35 additions & 3 deletions bin/rundoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,40 @@ class RundocThorCLI < Thor
def initialize(*args)
super
@path = options[:path]
@dotenv_path = options[:dotenv_path]
@on_success_dir = options[:on_success_dir]
@on_failure_dir = options[:on_failure_dir]
@output_filename = options[:output_filename]
@screenshots_dir = options[:screenshots_dir]
end

default_task :help

desc "build", "turns rundoc file into docs and a project"
class_option :path, banner: "path/to/file.md", optional: true, default: 'rundoc.md'
# class_option :output_dir, banner: "path/to/output_dir", optional: true, default: 'rundoc.md'
class_option :path,
banner: "<path/to/file/RUNDOC.md>"

class_option :on_success_dir,
banner: "<save/on/success/>",
optional: true

class_option :on_failure_dir,
banner: "<save/on/failure/>",
optional: true

class_option :output_filename,
banner: "Filename for the compiled output",
optional: true,
default: Rundoc::CLI::Defaults::OUTPUT_FILENAME

class_option :screenshots_dir,
banner: "Dirname for screenshots",
optional: true,
default: Rundoc::CLI::Defaults::SCREENSHOTS_DIR

class_option :dotenv_path,
banner: "<path/to/.env>",
optional: true

def build
if !File.exist?(@path)
Expand All @@ -36,7 +63,12 @@ class RundocThorCLI < Thor
end

Rundoc::CLI.new(
source_path: @path
source_path: @path,
dotenv_path: @dotenv_path,
on_failure_dir: @on_failure_dir,
on_success_dir: @on_success_dir,
output_filename: @output_filename,
screenshots_dir: @screenshots_dir
).call()
end
end
Expand Down
8 changes: 6 additions & 2 deletions lib/rundoc/cli.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module Rundoc
class CLI
module Defaults
OUTPUT_FILENAME = "README.md"
SCREENSHOTS_DIR = "screenshots"
end
attr_reader :io, :on_success_dir, :on_failure_dir, :dotenv_path, :cli_cmd, :cli_args
attr_reader :execution_context, :after_build_context

Expand All @@ -11,8 +15,8 @@ def initialize(
dotenv_path: nil,
on_success_dir: nil,
on_failure_dir: nil,
output_filename: "README.md",
screenshots_dir: "screenshots"
output_filename: Defaults::OUTPUT_FILENAME,
screenshots_dir: Defaults::SCREENSHOTS_DIR
)
@io = io
@execution_context = Rundoc::Context::Execution.new(
Expand Down

0 comments on commit ba102a8

Please sign in to comment.