lib/appifier/cli/templates.rb in appifier-0.1.2 vs lib/appifier/cli/templates.rb in appifier-0.2.0

- old
+ new

@@ -1,7 +1,7 @@ # frozen_string_literal: true - +require 'tty-markdown' module Appifier module CLI module Subcommands class Templates < ::Thor @@ -12,18 +12,62 @@ end # Thor method : list availables templates in user bundle desc 'ls', 'list templates availables in user bundle' def ls - Appifier::Components::Templates::list - @finisher.terminate exit_case: :error_exit + Appifier::Components::Template::list + @finisher.terminate exit_case: :quiet_exit end # Thor method : remove a template from user bundle desc 'rm', 'rm templates from user bundle' def rm(template) begin - Appifier::Components::Templates::rm(template) + Appifier::Components::Template::rm(template) + @output.info "Template #{template} removed" + @finisher.terminate exit_case: :quiet_exit + rescue RuntimeError => e + @output.error e.message + @finisher.terminate exit_case: :error_exit + end + end + + # Thor method : show information for a specific template in user bundle + desc 'show', 'show information for a specific template in user bundle' + def show(template) + begin + Appifier::Components::Template::show(template) + temp = Appifier::Components::Template::new(template: template) + if temp.readme? + puts " " + puts TTY::Markdown.parse_file(temp.readme_path) + end + + @finisher.terminate exit_case: :quiet_exit + rescue RuntimeError => e + @output.error e.message + @finisher.terminate exit_case: :error_exit + end + end + + # Thor method : display directory tree view for a specific template in user bundle + desc 'treeview', 'display directory tree view for a specific template in user bundle' + def treeview(template) + begin + Appifier::Components::Template::treeview(template) + @finisher.terminate exit_case: :quiet_exit + rescue RuntimeError => e + @output.error e.message + @finisher.terminate exit_case: :error_exit + end + end + + # Thor method : lint a specific template in user bundle + desc 'lint', 'Lint a specific template in user bundle' + def lint(template) + begin + Appifier::Components::Template::lint(template) + @finisher.terminate exit_case: :quiet_exit rescue RuntimeError => e @output.error e.message @finisher.terminate exit_case: :error_exit end end