Class: NanDoc::CreateNanDocSite
- Inherits:
-
Nanoc3::CLI::Commands::CreateSite
- Object
- Nanoc3::CLI::Commands::CreateSite
- NanDoc::CreateNanDocSite
- Includes:
- CliCommandHelpers, OptsNormalizer, TaskCommon
- Defined in:
- lib/nandoc/commands/create-nandoc-site.rb
Defined Under Namespace
Classes: StdErrListener, SupremeStderrHack
Instance Method Summary collapse
-
#aliases ⇒ Object
override create_site short!.
- #long_desc ⇒ Object
- #name ⇒ Object
- #option_definitions ⇒ Object
-
#run(opts, args, method_opts = {:_merge=>true}) ⇒ Object
On the _merge option: when we are doing a merge with a generated site and we want to generate a fresh site, we want to turn the below stderr hack off.
- #short_desc ⇒ Object
- #usage ⇒ Object
Methods included from OptsNormalizer
#exclusive_opt_flags, #normalize_opts, #unnormalize_opt_key, #unnormalize_opt_keys
Methods included from TaskCommon
Methods included from CliCommandHelpers
#command_name, #invite_to_more_command_help, #invocation_name
Methods included from PathHelper
Instance Method Details
#aliases ⇒ Object
override create_site short!
14 |
# File 'lib/nandoc/commands/create-nandoc-site.rb', line 14 def aliases; [ 'cnds', 'cns', 'cs' ] end |
#long_desc ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/nandoc/commands/create-nandoc-site.rb', line 18 def long_desc <<-D.gsub(/\n +/,' ') (nanDoc hack) Create a new site at the given path. This builds on the create_site nanoc3 command. Please see that for more information. Run this next to your README.md file. D end |
#name ⇒ Object
12 |
# File 'lib/nandoc/commands/create-nandoc-site.rb', line 12 def name; 'create_nandoc_site' end |
#option_definitions ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/nandoc/commands/create-nandoc-site.rb', line 28 def option_definitions [ { :long => 'patch-hack', :short => 'p', :argument => :none, :desc => '(nanDoc hack) use files not patches when necessary' }, { :long => 'merge-hack', :short => 'm', :argument => :none, :desc => '(nanDoc hack) when site already exists do something clever' }, { :long => 'merge-hack-reverse', :short => 'M', :argument => :none, :desc => '(nanDoc hack) show the reverse diff of above.' } ] end |
#run(opts, args, method_opts = {:_merge=>true}) ⇒ Object
On the _merge option: when we are doing a merge with a generated site and we want to generate a fresh site, we want to turn the below stderr hack off.
49 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 |
# File 'lib/nandoc/commands/create-nandoc-site.rb', line 49 def run(opts, args, method_opts={:_merge=>true}) opts = normalize_opts opts run_opts_process opts # # awful: see if nanoc triggers the error message about site # already existing, then take action # if method_opts[:_merge] StdErrListener.new do |listener| listener.when(/A site at '.*' already exists/) do throw :nandoc_hack, :site_already_exists end end end ret = nil thing = catch(:nandoc_hack) do ret = super(opts, args) :normal end case thing when :site_already_exists site_already_exists opts, args when :normal ret else fail("hack fail: #{thing.inspect}") end end |
#short_desc ⇒ Object
16 |
# File 'lib/nandoc/commands/create-nandoc-site.rb', line 16 def short_desc; 'create a nandoc site' end |
#usage ⇒ Object
26 |
# File 'lib/nandoc/commands/create-nandoc-site.rb', line 26 def usage; "nandoc create_nandoc_site [-m] <path>" end |