Class: Snaptoken::Commands::Step

Inherits:
BaseCommand show all
Defined in:
lib/snaptoken/commands/step.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCommand

#git_to_litdiff!, inherited, #initialize, #litdiff_to_git!, #needs!, #parseopts!

Constructor Details

This class inherits a constructor from Snaptoken::Commands::BaseCommand

Class Method Details

.nameObject



2
3
4
# File 'lib/snaptoken/commands/step.rb', line 2

def self.name
  "step"
end

.summaryObject



6
7
8
# File 'lib/snaptoken/commands/step.rb', line 6

def self.summary
  "Select a step for editing."
end

.usageObject



10
11
12
# File 'lib/snaptoken/commands/step.rb', line 10

def self.usage
  "<step-number>"
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/snaptoken/commands/step.rb', line 17

def run
  needs! :config, :repo

  step_number = @args.first.to_i

  FileUtils.cd(@git.repo_path) do
    @git.each_step do |cur_step, commit|
      if cur_step == step_number
        `git checkout #{commit.oid}`
        @git.copy_repo_to_step!
        exit
      end
    end

    puts "Error: Step not found."
    exit 1
  end
end

#setopts!(o) ⇒ Object



14
15
# File 'lib/snaptoken/commands/step.rb', line 14

def setopts!(o)
end