From ba102a8f3e1b822ae9aa5ead39170020e5f1f171 Mon Sep 17 00:00:00 2001 From: Schneems Date: Wed, 10 Jul 2024 15:10:56 -0500 Subject: [PATCH] Expose CLI inputs as flags --- README.md | 1 - bin/rundoc | 38 +++++++++++++++++++++++++++++++++++--- lib/rundoc/cli.rb | 8 ++++++-- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f4995a0..53560bb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/rundoc b/bin/rundoc index fa68657..0df9327 100755 --- a/bin/rundoc +++ b/bin/rundoc @@ -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: "" + + class_option :on_success_dir, + banner: "", + optional: true + + class_option :on_failure_dir, + banner: "", + 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: "", + optional: true def build if !File.exist?(@path) @@ -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 diff --git a/lib/rundoc/cli.rb b/lib/rundoc/cli.rb index 9fe74dc..30984e8 100644 --- a/lib/rundoc/cli.rb +++ b/lib/rundoc/cli.rb @@ -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 @@ -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(