#!/usr/bin/env ruby STDOUT.sync = true $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if RUBY_VERSION < '1.9' require 'rubygems' end require 'commander/import' require 'hyla' require 'hyla/project' program :version, Hyla::VERSION program :description, Hyla::DESCRIPTION # global_option '-s', '--source [DIR]', 'Source directory (defaults to ./)' # global_option '-d', '--destination [DIR]', 'Destination directory (defaults to .)' default_command :default def add_build_options(c) c.option '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file' c.option '-V', '--verbose', 'Print verbose output.' end def add_common_options(c) c.option '-s', '--source [DIR]', 'Source directory (defaults to ./)' c.option '-d', '--destination [DIR]', 'Destination directory (defaults to ./generated_content)' end # # Creates a new Hyla project using a template or blank to the PATH specified # command :new do |c| c.syntax = 'hyla new PATH' c.description = 'Creates a new Hyla project using a template or blank to the PATH specified' c.option '--f','--force', 'Force creation even if PATH already exists' c.option '--b','--blank', 'Creates project but with empty files' c.option '--t','--template_type TEMPLATE_TYPE', String, 'Template Type to be used (documentation, training, training-exercises, blog, web, ...)' c.action do |args, options| Hyla::Commands::New.process(args, options.__hash__) end end # # Creates a new file from an artefact within an existing project # command :create do |c| c.syntax = 'hyla create ARTEFACT TYPE' c.description = 'Creates a new file from asciidoc artefacts for an existing project' c.option '--a', '--artefact_type [ARTEFACT_TYPE]', String, 'Artefact Type : article, audio, video, blog entry ...' c.option '--d', '--destination [DIR]', String, 'Destination directory' c.option '--t', '--type [TYPE]', String, 'Type : asciidoc, slideshow' c.action do |args, options| Hyla::Commands::Create.process(args, options.__hash__) end end # # Generate from asciidoc files content according to rendering/transformation requested # command :generate do |c| c.syntax = 'hyla generate [OPTIONS]' c.description = 'Generate content from asciidoc files (Table Of Content, modules, ...) to HTML, Slideshow' c.option '--s', '--source [DIR]', String, 'Directory to be watched' c.option '--d', '--destination [DIR]', String, 'Destination directory' c.option '--p', '--project_name [PROJECT_NAME]', String, 'Project Name' c.option '--r', '--rendering [RENDERING]', String, 'Code of the rendering : toc2html, adoc2html' c.option '--t', '--toc [PATH]', String, 'File Path of the asciidoc file containing the Table of Content' c.action do |args, options| Hyla::Commands::Generate.process(args, options.__hash__) end end # Watch command :watch do |c| c.syntax = 'hyla watch [options]' c.description = 'Watch directories for any change, add or file deleted and render document (HTML5)' c.option '--d', '--destination DIR', String, 'Output directory where content must be generated' c.option '--s', '--source DIR', String, 'Directory to be watched' add_common_options(c) c.action do |args, options| options.default :serving => true # TODO Find if it is possible to watch files, generate HTML content - asciidoctor, expose content using HTTPServe and expose WebSocket - LiveReload # as they are started in 2 different threads, this is not possible with existing code # Hyla::Commands::Serve.process(args,options.__hash__) Hyla::Commands::Watch.process(args, options.__hash__) end end # Serve your content locally command :serve do |c| c.syntax = 'hyla serve [options]' c.description = 'Serve your content locally' c.option '--out_dir DIR', String, 'Output directory where content must be generated' c.option '-B', '--detach', 'Run the server in the background (detach)' c.option '-P', '--port [PORT]', 'Port to listen on' c.option '-H', '--host [HOST]', 'Host to bind to' c.option '-b', '--baseurl [URL]', 'Base URL' add_common_options(c) c.action do |args, options| options.default :serving => true Hyla::Commands::Serve.process(args, options.__hash__) end end alias_command :server, :serve # NOT YET AVAILABLE =begin # TODO NOT FINALISED # Reload command :reload do |c| c.syntax = 'hyla reload [options]' c.description = 'Reload HTML files generated within the browser - Livereload using WebSocket Server' c.action do |args, options| Hyla::Commands::Reload.process(options.__hash__) end end # Command generating output format from asciidoc files command :build do |c| c.syntax = 'hyla build [options]' c.description = 'Generating output content (HTML, PDF, ManPages, ...) from asciidoc(tor) files' c.option '--some-switch', 'Some switch that does something' c.action do |args, options| Hyla::Commands::Build.process(args, options.__hash__) end end command :publish do |c| c.syntax = 'hyla publish [options]' c.description = '' c.example 'description', 'command example' c.option '--some-switch', 'Some switch that does something' c.action do |args, options| Hyla::Commands::Publish.process(args, options.__hash__) end end =end