Class: NanDoc::Commands::Diff
- Inherits:
-
Cri::Command
- Object
- Cri::Command
- NanDoc::Commands::Diff
- Defined in:
- lib/nandoc/commands/diff.rb
Instance Method Summary collapse
- #aliases ⇒ Object
- #long_desc ⇒ Object
- #name ⇒ Object
- #option_definitions ⇒ Object
- #run(opts, args) ⇒ Object
- #short_desc ⇒ Object
- #usage ⇒ Object
Methods included from SiteMethods
Methods included from PathTardo
#hash_to_paths, #path_tardo, tardo_array_index
Methods included from NanDoc::Cli::OptionMethods
#exclusive_opt_flags, #normalize_opt_key, #normalize_opts, #option_enum, #unnormalize_opt_key, #unnormalize_opt_keys
Methods included from NanDoc::Cli::CommandMethods
#command_abort, #command_name, #command_path_assert, #invite_to_more_command_help, #invocation_name
Instance Method Details
#aliases ⇒ Object
16 |
# File 'lib/nandoc/commands/diff.rb', line 16 def aliases; [ 'd' ] end |
#long_desc ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nandoc/commands/diff.rb', line 22 def long_desc <<-LONG_DESC.gsub(/\n +/,' ') Patch a subtree of <my-site>/content with the same subtree in <my-site>/output with (--content-to-output|-c). (default). Opposite direction with -C. Patch a subtree of <prototypes>/<the-prototype> with the same subtree of <my-site>/content with (--content-to-prototype|-p). (For patching nanDoc prototypes.) Opposite direction with -P. This operates on a subset of the indicated trees, for now either the css folders in <my-site>/output/ and <my-site>/content/ or the layout folders between the prototype and the <my-site>. Indicate which with -s (css|layouts) (default: css) So, with this wierd chain, you can tweak your CSS, for example, in the generated output and then push these changes all the way back to the prototype with -cY and then -pY Or you can undo your changes pulling all the way back from the prototype with -PY and then -CY LONG_DESC end |
#name ⇒ Object
14 |
# File 'lib/nandoc/commands/diff.rb', line 14 def name; 'diff' end |
#option_definitions ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/nandoc/commands/diff.rb', line 50 def option_definitions pttp = 'pass-thru to patch. only for use with -Y' [ { :long => 'backup', :short => 'b', :argument=>:none, :desc => pttp }, { :long => 'content-to-output', :short => 'c', :argument => :none, :desc => 'show diff or patch content with output (default)' }, { :long => 'content-to-proto', :short => 'P', :argument => :none, :desc => 'show diff or patch content with proto (sure why not)' }, { :long => 'dry-run', :short => 'r', :argument => :none, :desc => pttp }, { :long => 'output-to-content', :short => 'C', :argument => :none, :desc => 'show diff or patch output with content (kind of weird)' }, { :long => 'patch', :short => 'Y', :argument => :none, :desc => 'apply the patch to the target (no undo!)' }, { :long => 'proto-to-content', :short => 'p', :argument => :none, :desc => ("show diff or patch prototype with content\n"<< (' '*22)+"(this would be for patching/altering nandoc)") }, { :long => 'subset', :short => 's', :argument => :required, :desc => "'css' or 'layouts' or 'js' (default: css)" } ] end |
#run(opts, args) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/nandoc/commands/diff.rb', line 80 def run opts, args opts = normalize_opts opts site_path = deduce_site_path_or_fail(args) src, dest = deduce_src_and_dest site_path, opts subset = subsets.parse(opts) if opts[:patch] # @todo this doesn't belong here probably patch_opts = process_patch_opts(opts, src, dest, site_path) go_patch src, dest, subset, site_path, patch_opts else process_diff_opts(opts) and fail("no more opts for this guy") go_diff src, dest, subset, site_path end end |
#short_desc ⇒ Object
18 19 20 |
# File 'lib/nandoc/commands/diff.rb', line 18 def short_desc "#{NanDoc::Config.option_prefix}maybe push and pull some stuff" end |
#usage ⇒ Object
46 47 48 |
# File 'lib/nandoc/commands/diff.rb', line 46 def usage; 'nandoc diff [-c|-C|-p|-P] [-s (css|layouts|js|root)] [-Y [-b]] [<path>]' end |