Usage

Command Line

AppArchetype when installed into your system is accessible through the archetype and app_archetype binary stubs. See commands for details on each of the commands available to you to use.

Script

An alternative method of usage is to create standalone ruby scripts for standalone exection (outside of the ARCHETYPE_TEMPLATE_DIR). As an example, the following describes a code component renderer, where a command class for a simple CLI application can be rendered automatically.

For this example you may wish to introduce a scripts folder to a project:

mkdir path/to/my_project/scripts

And under that make an archetypes template directory:

 - 📁 path/to/my_project/scripts
 | - 📁 generators/
 | - | - 📁 command/
 | - | - | - 📁 template/
 | - | - | - | - 📁 lib/
 | - | - | - | - | 📁 app_archetype/
 | - | - | - | - | - | 📁 commands/
 | - | - | - | - | - | - | 📄 {{command_name.snake_case}}.rb.hbs
 | - | - | - 📄 manifest.json
 | - | 📄 create_new_command

A standalone generator can be written using the standalone render method exposed in the AppArchetype namespace. The following would be the content of the create_new_command script.

#!/usr/bin/env ruby

require_relative '../lib/app_archetype'

puts 'CREATE NEW COMMAND'

manifest = AppArchetype.render_template(
  collection_dir: File.join(__dir__, 'generators'),
  template_name: 'command',
  destination_path: File.expand_path(File.join(__dir__, '..'))
)

command_name = manifest.variables.get('command_name').value

next_steps = <<~TEXT
   Command created

  TODO:

  Add the following to cli.rb within AppArchetype::CLI:

  desc '#{command_name.snake_case}', 'TODO: description'

  def #{command_name.snake_case}
    cmd =  AppArchetype::Commands::#{command_name.camel_case}.new(options)
    cmd.run
  end
TEXT

puts next_steps