lib/gumdrop/cli/internal.rb in gumdrop-0.8.0 vs lib/gumdrop/cli/internal.rb in gumdrop-1.0.0

- old
+ new

@@ -12,33 +12,37 @@ desc 'build', 'Build project' method_option :env, default:'production', aliases:'-e' method_option :assets, aliases:'-a', type: :array, desc:"List of assets to render." method_option :quiet, default:false, aliases:'-q', type: :boolean - method_option :subdued, default:false, aliases:'-s', type: :boolean, desc:"Subdued output (....)" method_option :resume, default:false, aliases:'-r', type: :boolean, desc:"Auto resume rendering after any errors" - def build() - Gumdrop.run(options) + method_option :force, default:false, aliases:'-f', type: :boolean, desc:"Ignore file checksums and create all files" + def build + if options[:quiet] + Gumdrop.configure do |c| + c.log_level= :warn + end + end + Gumdrop.run options.merge(mode:'build') end desc 'server', 'Run development server' - method_option :env, default:'production', aliases:'-e' def server + Gumdrop.site.options = options.merge(mode:'build') Gumdrop::Server end desc 'watch', "Watch filesystem for changes and recompile" - method_option :env, default:'production', aliases:'-e' method_option :quiet, default:false, aliases:'-q', type: :boolean method_option :subdued, default:false, aliases:'-s', type: :boolean, desc:"Subdued output (....)" method_option :resume, default:false, aliases:'-r', type: :boolean, desc:"Auto resume rendering after any errors" def watch - Gumdrop.run options - paths= [SITE.src_path] - paths << SITE.data_path if File.directory? SITE.data_path + Gumdrop.run options.merge(mode:'merge') + paths= [Gumdrop.site.source_dir, Gumdrop.site.sitefile] #? Sitefile too? + paths << Gumdrop.site.data_dir if File.directory? Gumdrop.site.data_dir Listen.to(*paths, :latency => 0.5) do |m, a, r| - SITE.rebuild + Gumdrop.rebuild options.merge(mode:'merge') end end desc 'template [NAME]', "Create local template from this project" def template(name) @@ -48,28 +52,56 @@ say "A template named '#{name}' already exists!" else say "Creating template: #{name}" say " ~/.gumdrop/templates/#{name}" - site_root= Gumdrop.site_dirname + site_root= Gumdrop.site.root FileUtils.mkdir_p File.dirname(template_path) - FileUtils.cp_r File.join(site_root, "."), template_path + FileUtils.cp_r (site_root / "."), template_path end end - private - - def home_path(name="") - File.expand_path File.join("~", ".gumdrop", name) - end - def home_template_path(template) - home_path 'tempaltes', template + desc 'uris', "Print list of the uri that will be generated." + def uris + Gumdrop.configure do |c| + c.log_level= :error end + Gumdrop.site.scan - def local_path(name="") - File.join( ".", name ) # ? + say "Gumdrop found:" + say "" + Gumdrop.site.contents.keys.sort.each do |uri| + content= Gumdrop.site.contents[uri] + blackout= Gumdrop.site.in_blacklist?(uri) ? 'X' : ' ' + generated= content.generated? ? '*' : ' ' + binary= content.binary? ? '!' : ' ' + say " #{blackout + generated + binary} #{content.uri}" end + say "" + say "Legend:" + say " X = On on the blacklist" + say " * = Generated (not on fs)" + say " ! = Binary file" + end + + desc "version", "Displays Gumdrop version" + def version + say "Gumdrop v#{ Gumdrop::VERSION }" + end + + + private + + def home_path(name="") + File.expand_path "~" /".gumdrop" / name + end + + def home_template_path(template) + home_path 'templates' / template + end + + def local_path(name="") + "." / name + end end end - -SITE= Gumdrop::Site.new Gumdrop.fetch_site_file unless defined?( SITE )