Commit d658c9a3 authored by f's avatar f
Browse files

start a new container

parent adbcd8fd
......@@ -19,6 +19,18 @@ module Sutty
end
map %w(--version -v) => :version
desc 'container NAME', 'Adds a container'
method_option :help, aliases: '-h', type: :boolean,
desc: 'Display usage information'
def container(name)
if options[:help]
invoke :help, ['container']
else
require_relative 'commands/container'
Sutty::Cli::Commands::Container.new(name, options).execute
end
end
desc 'theme NAME', 'Start a new theme'
method_option :help, aliases: '-h', type: :boolean,
desc: 'Display usage information'
......
# frozen_string_literal: true
require_relative '../command'
require 'tty-command'
module Sutty
module Cli
module Commands
class Container < Sutty::Cli::Command
attr_reader :name
def initialize(name, options)
@name = name
@options = options
end
def execute(input: $stdin, output: $stdout)
cmd.run('git clone https://0xacab.org/sutty/containers/skel.git', name)
Dir.chdir name do
cmd.run('git remote rename origin upstream')
cmd.run('git remote add origin', origin)
cmd.run('git push -u origin master')
end
end
private
def origin
@origin ||= 'git@0xacab.org:sutty/containers/' + name + '.git'
end
def cmd
@cmd ||= TTY::Command.new
end
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment