Skip to content

Commit dcb65c4

Browse files
committed
Fixed version command
Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
1 parent ace1dd8 commit dcb65c4

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

cfengine_cli/commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from cfengine_cli.shell import user_command
22
from cfengine_cli.paths import bin
3+
from cfengine_cli.version import string as version_string
34

45

56
def run() -> int:
@@ -18,3 +19,8 @@ def help() -> int:
1819
print("Example usage:")
1920
print("cfengine run")
2021
return 0
22+
23+
24+
def version() -> int:
25+
print(version_string())
26+
return 0

cfengine_cli/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ def _get_arg_parser():
5050
help="Run the agent and hub commands necessary to get new reporting data",
5151
)
5252

53+
subp.add_parser(
54+
"version",
55+
help="Print the version string",
56+
)
57+
5358
return ap
5459

5560

@@ -66,6 +71,8 @@ def run_command_with_args(command, _) -> int:
6671
return commands.report()
6772
if command == "help":
6873
return commands.help()
74+
if command == "version":
75+
return commands.versions()
6976
raise UserError("Unknown command: '{}'".format(command))
7077

7178

cfengine_cli/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class UserError(Exception):
33

44
def __init__(self, message):
55
super().__init__(message)
6+
self.message = message
67

78
def __str__(self):
89
return f"Error: {self.message}"

0 commit comments

Comments
 (0)