Class: Stic::CLI::Command

Inherits:
Opt::Command
  • Object
show all
Defined in:
lib/stic/cli/command.rb

Direct Known Subclasses

Build

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define(name, &block) ⇒ Object



35
36
37
38
39
# File 'lib/stic/cli/command.rb', line 35

def define(name, &block)
  CLI.parser.commands << new(name).tap do |cmd|
    cmd.instance_eval(&block)
  end
end

Instance Method Details

#run(_result) ⇒ Object



5
6
7
8
# File 'lib/stic/cli/command.rb', line 5

def run(_result)
  raise NotImplementedError.new "Subclass #{self.class.name} to " \
                                'implement custom command.'
end

#siteObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/stic/cli/command.rb', line 10

def site
  @site ||= begin
    Stic::Site.lookup.tap do |site|
      unless site
        puts 'Not in a stic site. You need to run the ' \
             '`stic` command within a stic site.'
        exit 1
      end
    end
  end
end

#to_helpObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/stic/cli/command.rb', line 22

def to_help
  <<-EOF.gsub(/^ {4}/, '')
    build
        Build current side ot given output path.

        --target, -t
            Output path the side will be written to. Existing files
            will be overriden and/or deleted. Defaults to `site`
            in project root. (Not yet supported)
  EOF
end