inspec/lib/bundles/inspec-habitat/cli.rb
Adam Leff 0342cca62e Adding a Habitat profile artifact creator
Two new commands have been created:

 * inspec habitat profile create /path/to/profile
 * inspec habitat profile upload /path/to/profile

The `create` command creates a Habitat artifact that contains the contents
of the Habitat profile found at the provided path. This will be used later
in some Habitat + InSpec integrations.

The `upload` command does the same create process but then uploads the
resulting artifact to the Habitat Depot.

Signed-off-by: Adam Leff <adam@leff.co>
2017-02-23 18:25:22 -05:00

32 lines
984 B
Ruby

# encoding: utf-8
# author: Adam Leff
require 'thor'
module Habitat
class HabitatProfileCLI < Thor
namespace 'habitat profile'
desc 'create PATH', 'Create a Habitat artifact for the profile found at PATH'
option :output_dir, type: :string, required: false,
desc: 'Directory in which to save the generated Habitat artifact. Default: current directory'
def create(path)
puts options
Habitat::Profile.create(path, options)
end
desc 'upload PATH', 'Create a Habitat artifact for the profile found at PATH, and upload it to a Habitat Depot'
def upload(path)
Habitat::Profile.upload(path, options)
end
end
class HabitatCLI < Inspec::BaseCLI
namespace 'habitat'
desc 'profile', 'Manage InSpec profiles as Habitat artifacts'
subcommand 'profile', HabitatProfileCLI
end
Inspec::Plugins::CLI.add_subcommand(HabitatCLI, 'habitat', 'habitat SUBCOMMAND ...', 'Commands for InSpec + Habitat Integration', {})
end