Class: Options

Inherits:
SwiftObject show all
Defined in:
lib/branch_cli/options.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SwiftObject

#initialize, let, var, variable_defaults

Constructor Details

This class inherits a constructor from SwiftObject

Class Method Details

.resetObject



6
7
8
# File 'lib/branch_cli/options.rb', line 6

def self.reset
  @sharedInstance = nil
end

.sharedInstanceObject



2
3
4
# File 'lib/branch_cli/options.rb', line 2

def self.sharedInstance
  @sharedInstance ||= Options.new
end

Instance Method Details

#isBranchSuppliedObject



19
20
21
# File 'lib/branch_cli/options.rb', line 19

def isBranchSupplied
  return suppliedBranch != nil
end

#loadOptions(arguments: nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/branch_cli/options.rb', line 23

def loadOptions(arguments: nil)
  if arguments.contains("help") || arguments.contains("--help")
    self.isHelp = true
  end

  if arguments.contains("--verbose")
    self.isVerbose = true
  end

  if arguments.contains("-v") || arguments.contains("--version")
    self.isShowVersion = true
  end

  if arguments.contains("--test-rebase")
    self.isTestRebase = true
  end

  if arguments.contains("--list") || arguments.contains("-l")
    self.isShowList = true
  end

  if arguments.contains("--prefer=local")
    self.preferLocal = true
  end

  if arguments.contains("--prefer=remote")
    self.preferRemote = true
  end

  if arguments.count > 0
    if !arguments[0].hasPrefix("-")
      self.suppliedBranch = arguments[0]
    end
  end
end