Skip to content

Commit 1ee5453

Browse files
committed
[CPFeature-008] Updated main with the new interface and changed version output to be more consistent with the other outputs
1 parent cecac85 commit 1ee5453

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

Sources/CommitPrefix/main.swift

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,45 +27,39 @@
2727
import Consler
2828
import Foundation
2929

30-
let cpCommandLineInterface = CLIArguments()
30+
let commandLineInterface = CLIArguments()
31+
let cpInterface = CommitPrefix.interface()
3132

3233
do {
3334

34-
switch try cpCommandLineInterface.getCommand() {
35+
switch try commandLineInterface.getCommand() {
3536

3637
case .outputVersion:
37-
Consler.output(
38-
"CommitPrefix ", "version ", CPInfo.version,
39-
descriptors: [.normal, .cyan, .cyan])
38+
let versionOutput = cpInterface.outputVersion()
39+
Consler.output(versionOutput)
4040

4141
case .viewState:
42-
let fileHandler = try CPFileHandler()
43-
let viewStateOutput = try fileHandler.viewState()
42+
let viewStateOutput = try cpInterface.viewState()
4443
Consler.output(viewStateOutput)
4544

4645
case .outputPrefixes:
47-
let fileHandler = try CPFileHandler()
48-
let prefixesOutput = try fileHandler.outputPrefixes()
46+
let prefixesOutput = try cpInterface.outputPrefixes()
4947
Consler.output(prefixesOutput)
5048

5149
case .deletePrefixes:
52-
let fileHandler = try CPFileHandler()
53-
let deletionOutput = try fileHandler.deletePrefixes()
50+
let deletionOutput = try cpInterface.deletePrefixes()
5451
Consler.output(deletionOutput)
5552

5653
case .modeNormal:
57-
let fileHandler = try CPFileHandler()
58-
let normalModeOutput = try fileHandler.activateNormalMode()
54+
let normalModeOutput = try cpInterface.activateNormalMode()
5955
Consler.output(normalModeOutput)
6056

6157
case .modeBranchParse(validator: let rawValidatorValue):
62-
let fileHandler = try CPFileHandler()
63-
let branchModeOutput = try fileHandler.activateBranchMode(with: rawValidatorValue)
58+
let branchModeOutput = try cpInterface.activateBranchMode(with: rawValidatorValue)
6459
Consler.output(branchModeOutput)
6560

6661
case .newPrefixes(value: let rawPrefixValue):
67-
let fileHandler = try CPFileHandler()
68-
let newPrefixesOutput = try fileHandler.writeNew(prefixes: rawPrefixValue)
62+
let newPrefixesOutput = try cpInterface.writeNew(prefixes: rawPrefixValue)
6963
Consler.output(newPrefixesOutput)
7064

7165
}

0 commit comments

Comments
 (0)