class Mark::Options

Overview

Wraps arguments and options from CLI. Handles setting defaults and running validations.

Example usage:

options = Mark::Options.new(["source.md"], { :target => "/path/to/target.html" })
options.sources         # => ["source.md"]
options.target          # => "/path/to/target.html"
options.template_html   # => ".... default html template ..."
options.open_command    # => "open /path/to/target.html"
options.keep            # => false
options.keep_for        # => 300
options.validate!       # => no-op since all options are valid

options = Mark::Options.new([], { :target => "/path/to/target.html" })
options.validate!       # => raises OptionError, at least one source required

Defined in:

mark/options.cr

Constant Summary

DEFAULT_KEEP_FOR = "300"
DEFAULT_OPEN = "open %"
DEFAULT_TARGET = ".mark.html"
DEFAULT_TEMPLATE = File.join(ENV["HOME"], ".mark", "template.html")

Constructors

Instance Method Summary

Constructor Detail

def self.new(sources : Array(String), options : Hash(Symbol, String)) #

[View source]

Instance Method Detail

def keep : Bool #

[View source]
def keep_for_seconds #

[View source]
def open_command #

[View source]
def sources : Array(String) #

[View source]
def target : String #

[View source]
def target_directory #

[View source]
def template_html #

[View source]
def validate! #

[View source]