gibson-cli 0.4.0__py3-none-any.whl → 0.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gibson/api/Cli.py +17 -1
- gibson/command/Build.py +14 -4
- gibson/command/Code.py +7 -7
- gibson/command/Conf.py +14 -11
- gibson/command/Count.py +6 -4
- gibson/command/Dev.py +9 -4
- gibson/command/Forget.py +12 -13
- gibson/command/Help.py +125 -0
- gibson/command/Import.py +18 -8
- gibson/command/List.py +7 -3
- gibson/command/Merge.py +2 -4
- gibson/command/Model.py +4 -4
- gibson/command/Modify.py +4 -6
- gibson/command/Module.py +5 -6
- gibson/command/New.py +3 -5
- gibson/command/OpenApi.py +8 -7
- gibson/command/Question.py +16 -8
- gibson/command/Remove.py +5 -4
- gibson/command/Rename.py +5 -5
- gibson/command/Schema.py +4 -4
- gibson/command/Show.py +9 -6
- gibson/command/Test.py +5 -5
- gibson/command/Tree.py +2 -1
- gibson/command/auth/Auth.py +2 -2
- gibson/command/rewrite/Rewrite.py +5 -3
- gibson/conf/Paths.py +2 -0
- gibson/core/Colors.py +4 -0
- gibson/core/CommandRouter.py +7 -122
- gibson/core/Configuration.py +74 -83
- gibson/core/Env.py +3 -0
- gibson/core/Memory.py +4 -3
- gibson/services/auth/Server.py +1 -1
- {gibson_cli-0.4.0.dist-info → gibson_cli-0.5.1.dist-info}/METADATA +5 -3
- {gibson_cli-0.4.0.dist-info → gibson_cli-0.5.1.dist-info}/RECORD +37 -36
- {gibson_cli-0.4.0.dist-info → gibson_cli-0.5.1.dist-info}/WHEEL +1 -1
- {gibson_cli-0.4.0.dist-info → gibson_cli-0.5.1.dist-info}/entry_points.txt +0 -0
- {gibson_cli-0.4.0.dist-info → gibson_cli-0.5.1.dist-info}/top_level.txt +0 -0
gibson/command/Module.py
CHANGED
@@ -3,6 +3,7 @@ import sys
|
|
3
3
|
|
4
4
|
from gibson.api.Cli import Cli
|
5
5
|
from gibson.command.BaseCommand import BaseCommand
|
6
|
+
from gibson.core.Colors import command, hint, input, subcommand
|
6
7
|
|
7
8
|
|
8
9
|
class Module(BaseCommand):
|
@@ -10,8 +11,9 @@ class Module(BaseCommand):
|
|
10
11
|
if len(sys.argv) != 3:
|
11
12
|
self.usage()
|
12
13
|
|
14
|
+
self.configuration.ensure_project()
|
13
15
|
if not re.search("^[a-z0-9]+$", sys.argv[2]):
|
14
|
-
self.
|
16
|
+
self.configuration.display_project()
|
15
17
|
self.conversation.type("[module name] should only contain ^[a-z0-9]+$.\n\n")
|
16
18
|
return True
|
17
19
|
|
@@ -30,12 +32,9 @@ class Module(BaseCommand):
|
|
30
32
|
self.conversation.newline()
|
31
33
|
|
32
34
|
def usage(self):
|
33
|
-
self.
|
35
|
+
self.configuration.display_project()
|
34
36
|
self.conversation.type(
|
35
|
-
f"usage: {self.configuration.command} module [module name]\n"
|
36
|
-
+ " where [module name] is the name of the module I should create for "
|
37
|
-
+ "this project\n"
|
38
|
-
+ " [module name] ~ ^[a-z0-9]+$\n"
|
37
|
+
f"usage: {command(self.configuration.command)} {subcommand('module')} {input('[module name]')} {hint('create a new module for this project')}\n"
|
39
38
|
)
|
40
39
|
self.conversation.newline()
|
41
40
|
exit(1)
|
gibson/command/New.py
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
import os
|
2
|
-
import re
|
3
1
|
import sys
|
4
2
|
|
5
3
|
from gibson.api.Cli import Cli
|
6
4
|
from gibson.command.BaseCommand import BaseCommand
|
5
|
+
from gibson.core.Colors import argument, command, hint, subcommand
|
7
6
|
|
8
7
|
|
9
8
|
class New(BaseCommand):
|
@@ -28,10 +27,9 @@ class New(BaseCommand):
|
|
28
27
|
self.conversation.configure_new_project(self.configuration)
|
29
28
|
|
30
29
|
def usage(self):
|
31
|
-
self.
|
30
|
+
self.configuration.display_project()
|
32
31
|
self.conversation.type(
|
33
|
-
f"usage: {self.configuration.command} new
|
34
|
-
+ ' where [thing] can only be "project", for now\n'
|
32
|
+
f"usage: {command(self.configuration.command)} {subcommand('new')} {argument('project')} {hint('create a new project')}\n"
|
35
33
|
)
|
36
34
|
self.conversation.newline()
|
37
35
|
exit(1)
|
gibson/command/OpenApi.py
CHANGED
@@ -4,11 +4,12 @@ import sys
|
|
4
4
|
|
5
5
|
from gibson.api.Cli import Cli
|
6
6
|
from gibson.command.BaseCommand import BaseCommand
|
7
|
+
from gibson.core.Colors import command, hint, input, subcommand
|
7
8
|
|
8
9
|
|
9
10
|
class OpenApi(BaseCommand):
|
10
11
|
def bad_json(self):
|
11
|
-
self.
|
12
|
+
self.configuration.display_project()
|
12
13
|
self.conversation.type(
|
13
14
|
"I need valid JSON. That file does not appear to be that. Try again?\n"
|
14
15
|
)
|
@@ -30,7 +31,8 @@ class OpenApi(BaseCommand):
|
|
30
31
|
if "paths" not in contents:
|
31
32
|
self.unrecognized_format()
|
32
33
|
|
33
|
-
self.
|
34
|
+
self.configuration.ensure_project()
|
35
|
+
self.configuration.display_project()
|
34
36
|
|
35
37
|
if contents.get("info", None) is not None:
|
36
38
|
if contents["info"].get("title", None) is not None:
|
@@ -115,7 +117,7 @@ class OpenApi(BaseCommand):
|
|
115
117
|
return True
|
116
118
|
|
117
119
|
def file_not_found(self):
|
118
|
-
self.
|
120
|
+
self.configuration.display_project()
|
119
121
|
self.conversation.type(
|
120
122
|
f'Well that embarrassing. There is no file "{sys.argv[2]}".\n'
|
121
123
|
)
|
@@ -123,7 +125,7 @@ class OpenApi(BaseCommand):
|
|
123
125
|
exit(1)
|
124
126
|
|
125
127
|
def unrecognized_format(self):
|
126
|
-
self.
|
128
|
+
self.configuration.display_project()
|
127
129
|
self.conversation.type(
|
128
130
|
"Well that sucks. I do not recognize this JSON format.\n"
|
129
131
|
)
|
@@ -131,10 +133,9 @@ class OpenApi(BaseCommand):
|
|
131
133
|
exit(1)
|
132
134
|
|
133
135
|
def usage(self):
|
134
|
-
self.
|
136
|
+
self.configuration.display_project()
|
135
137
|
self.conversation.type(
|
136
|
-
f"usage: {self.configuration.command} openapi [file path]"
|
137
|
-
+ "\n where [file path] is the full path to an OpenAPI spec\n"
|
138
|
+
f"usage: {command(self.configuration.command)} {subcommand('openapi')} {input('[file path]')} {hint('import entities from an OpenAPI spec file')}\n"
|
138
139
|
)
|
139
140
|
self.conversation.newline()
|
140
141
|
exit(1)
|
gibson/command/Question.py
CHANGED
@@ -3,6 +3,7 @@ import sys
|
|
3
3
|
|
4
4
|
from gibson.api.Cli import Cli
|
5
5
|
from gibson.command.BaseCommand import BaseCommand
|
6
|
+
from gibson.core.Colors import argument, command, hint, input, subcommand
|
6
7
|
|
7
8
|
|
8
9
|
class Question(BaseCommand):
|
@@ -14,6 +15,7 @@ class Question(BaseCommand):
|
|
14
15
|
if len(sys.argv) < 3:
|
15
16
|
self.usage()
|
16
17
|
|
18
|
+
self.configuration.ensure_project()
|
17
19
|
instructions = ""
|
18
20
|
has_file = False
|
19
21
|
has_python = False
|
@@ -80,25 +82,31 @@ class Question(BaseCommand):
|
|
80
82
|
self.conversation.newline()
|
81
83
|
|
82
84
|
def __file_not_found(self, path):
|
83
|
-
self.
|
85
|
+
self.configuration.display_project()
|
84
86
|
self.conversation.type(f'404, My Friend. Cannot find file "{path}".\n')
|
85
87
|
self.conversation.newline()
|
86
88
|
exit(1)
|
87
89
|
|
88
90
|
def __python_import_not_found(self, import_):
|
89
|
-
self.
|
91
|
+
self.configuration.display_project()
|
90
92
|
self.conversation.type(f'That\'s a misfire, "{import_}" does not exist.\n')
|
91
93
|
self.conversation.newline()
|
92
94
|
exit(1)
|
93
95
|
|
94
96
|
def usage(self):
|
95
|
-
self.
|
97
|
+
self.configuration.display_project()
|
96
98
|
self.conversation.type(
|
97
|
-
f"usage: {self.configuration.command}
|
98
|
-
+ " where [instructions] is natural language\n"
|
99
|
-
+ f" use {self.TOKEN_FILE}[path] to import a file from the filesystem\n"
|
100
|
-
+ f" use {self.TOKEN_PYTHON}[import] to import a file from PYTHONPATH\n"
|
101
|
-
+ f" use {self.TOKEN_SQL}[entity name] to import the SQL\n"
|
99
|
+
f"usage: {command(self.configuration.command)} {subcommand('q')} {input('[instructions]')} {hint('ask a question or tell Gibson to do something using natural language')}\n"
|
102
100
|
)
|
101
|
+
self.conversation.type(
|
102
|
+
f" use {argument(self.TOKEN_FILE+'[path]')} to import a file from the filesystem\n"
|
103
|
+
)
|
104
|
+
self.conversation.type(
|
105
|
+
f" use {argument(self.TOKEN_PYTHON+'[import]')} to import a file from PYTHONPATH\n"
|
106
|
+
)
|
107
|
+
self.conversation.type(
|
108
|
+
f" use {argument(self.TOKEN_SQL+'[entity name]')} to import SQL\n"
|
109
|
+
)
|
110
|
+
|
103
111
|
self.conversation.newline()
|
104
112
|
exit(1)
|
gibson/command/Remove.py
CHANGED
@@ -3,6 +3,7 @@ import sys
|
|
3
3
|
from gibson.api.Cli import Cli
|
4
4
|
from gibson.command.BaseCommand import BaseCommand
|
5
5
|
from gibson.command.rewrite.Rewrite import Rewrite
|
6
|
+
from gibson.core.Colors import command, hint, input, subcommand
|
6
7
|
|
7
8
|
|
8
9
|
class Remove(BaseCommand):
|
@@ -10,7 +11,8 @@ class Remove(BaseCommand):
|
|
10
11
|
if len(sys.argv) != 3:
|
11
12
|
self.usage()
|
12
13
|
|
13
|
-
self.
|
14
|
+
self.configuration.ensure_project()
|
15
|
+
self.configuration.display_project()
|
14
16
|
|
15
17
|
found = False
|
16
18
|
|
@@ -70,10 +72,9 @@ class Remove(BaseCommand):
|
|
70
72
|
return self
|
71
73
|
|
72
74
|
def usage(self):
|
73
|
-
self.
|
75
|
+
self.configuration.display_project()
|
74
76
|
self.conversation.type(
|
75
|
-
f"usage: {self.configuration.command} remove [entity name]\n"
|
76
|
-
+ " where [entity name] is one of the entities that exists in this project\n"
|
77
|
+
f"usage: {command(self.configuration.command)} {subcommand('remove')} {input('[entity name]')} {hint('remove an entity from the project')}\n"
|
77
78
|
)
|
78
79
|
self.conversation.newline()
|
79
80
|
exit(1)
|
gibson/command/Rename.py
CHANGED
@@ -3,6 +3,7 @@ import sys
|
|
3
3
|
from gibson.api.Cli import Cli
|
4
4
|
from gibson.command.BaseCommand import BaseCommand
|
5
5
|
from gibson.command.rewrite.Rewrite import Rewrite
|
6
|
+
from gibson.core.Colors import argument, command, hint, input, subcommand
|
6
7
|
|
7
8
|
|
8
9
|
class Rename(BaseCommand):
|
@@ -10,7 +11,8 @@ class Rename(BaseCommand):
|
|
10
11
|
if len(sys.argv) != 4:
|
11
12
|
self.usage()
|
12
13
|
|
13
|
-
self.
|
14
|
+
self.configuration.ensure_project()
|
15
|
+
self.configuration.display_project()
|
14
16
|
|
15
17
|
if self.memory.recall_entity(sys.argv[2]) is None:
|
16
18
|
self.conversation.type(
|
@@ -60,11 +62,9 @@ class Rename(BaseCommand):
|
|
60
62
|
return self
|
61
63
|
|
62
64
|
def usage(self):
|
63
|
-
self.
|
65
|
+
self.configuration.display_project()
|
64
66
|
self.conversation.type(
|
65
|
-
f"usage: {self.configuration.command} rename [current] [new]\n"
|
66
|
-
+ " where [current] is the name of an entity and [new] is what "
|
67
|
-
+ "you want to call it\n"
|
67
|
+
f"usage: {command(self.configuration.command)} {subcommand('rename')} {argument('[current]')} {input('[new]')} {hint('rename an entity')}\n"
|
68
68
|
)
|
69
69
|
self.conversation.newline()
|
70
70
|
exit(1)
|
gibson/command/Schema.py
CHANGED
@@ -2,6 +2,7 @@ import sys
|
|
2
2
|
|
3
3
|
from gibson.api.Cli import Cli
|
4
4
|
from gibson.command.BaseCommand import BaseCommand
|
5
|
+
from gibson.core.Colors import argument, command, hint, subcommand
|
5
6
|
from gibson.core.TimeKeeper import TimeKeeper
|
6
7
|
from gibson.dev.Dev import Dev
|
7
8
|
|
@@ -11,6 +12,7 @@ class Schema(BaseCommand):
|
|
11
12
|
if len(sys.argv) != 3:
|
12
13
|
self.usage()
|
13
14
|
|
15
|
+
self.configuration.ensure_project()
|
14
16
|
entity = self.memory.recall_stored_entity(sys.argv[2])
|
15
17
|
if entity is None:
|
16
18
|
self.conversation.not_sure_no_entity(
|
@@ -31,11 +33,9 @@ class Schema(BaseCommand):
|
|
31
33
|
time_keeper.display()
|
32
34
|
|
33
35
|
def usage(self):
|
34
|
-
self.
|
36
|
+
self.configuration.display_project()
|
35
37
|
self.conversation.type(
|
36
|
-
f"usage: {self.configuration.command} schema [entity name]\n"
|
37
|
-
+ " where [entity name] is one of the entities that exists in "
|
38
|
-
+ "this project\n"
|
38
|
+
f"usage: {command(self.configuration.command)} {subcommand('schema')} {argument('[entity name]')} {hint('write the schema code for an entity')}\n"
|
39
39
|
)
|
40
40
|
self.conversation.newline()
|
41
41
|
exit(1)
|
gibson/command/Show.py
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
import sys
|
2
2
|
|
3
|
-
from .BaseCommand import BaseCommand
|
3
|
+
from gibson.command.BaseCommand import BaseCommand
|
4
|
+
from gibson.core.Colors import argument, command, hint, subcommand
|
4
5
|
|
5
6
|
|
6
7
|
class Show(BaseCommand):
|
7
8
|
def execute(self):
|
8
9
|
if len(sys.argv) == 2:
|
10
|
+
self.configuration.ensure_project()
|
9
11
|
entities = self.memory.recall_merged()
|
10
12
|
if entities is None:
|
11
13
|
self.conversation.cant_no_entities(self.configuration.project.name)
|
12
14
|
exit(1)
|
13
15
|
elif len(sys.argv) == 3:
|
16
|
+
self.configuration.ensure_project()
|
14
17
|
entity = self.memory.recall_entity(sys.argv[2])
|
15
18
|
if entity is None:
|
16
19
|
self.conversation.not_sure_no_entity(
|
@@ -26,12 +29,12 @@ class Show(BaseCommand):
|
|
26
29
|
print(entity["definition"])
|
27
30
|
|
28
31
|
def usage(self):
|
29
|
-
self.
|
32
|
+
self.configuration.display_project()
|
30
33
|
self.conversation.type(
|
31
|
-
f"usage: {self.configuration.command} show {
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
f"usage: {command(self.configuration.command)} {subcommand('show')} {hint('display the entire schema')}\n"
|
35
|
+
)
|
36
|
+
self.conversation.type(
|
37
|
+
f" or: {command(self.configuration.command)} {subcommand('show')} {argument('[entity name]')} {hint('display the schema for an entity')}\n"
|
35
38
|
)
|
36
39
|
self.conversation.newline()
|
37
40
|
exit(1)
|
gibson/command/Test.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import sys
|
2
2
|
|
3
3
|
from gibson.api.Cli import Cli
|
4
|
-
from gibson.dev.Dev import Dev
|
5
4
|
from gibson.command.BaseCommand import BaseCommand
|
5
|
+
from gibson.core.Colors import argument, command, hint, subcommand
|
6
6
|
from gibson.core.TimeKeeper import TimeKeeper
|
7
|
+
from gibson.dev.Dev import Dev
|
7
8
|
|
8
9
|
|
9
10
|
class Test(BaseCommand):
|
@@ -11,6 +12,7 @@ class Test(BaseCommand):
|
|
11
12
|
if len(sys.argv) != 3:
|
12
13
|
self.usage()
|
13
14
|
|
15
|
+
self.configuration.ensure_project()
|
14
16
|
entity = self.memory.recall_stored_entity(sys.argv[2])
|
15
17
|
if entity is None:
|
16
18
|
self.conversation.not_sure_no_entity(
|
@@ -31,11 +33,9 @@ class Test(BaseCommand):
|
|
31
33
|
time_keeper.display()
|
32
34
|
|
33
35
|
def usage(self):
|
34
|
-
self.
|
36
|
+
self.configuration.display_project()
|
35
37
|
self.conversation.type(
|
36
|
-
f"usage: {self.configuration.command} test [entity name]\n"
|
37
|
-
+ " where [entity name] is one of the entities that exists "
|
38
|
-
+ "in this project\n"
|
38
|
+
f"usage: {command(self.configuration.command)} {subcommand('test')} {argument('[entity name]')} {hint('write the unit tests for an entity')}\n"
|
39
39
|
)
|
40
40
|
self.conversation.newline()
|
41
41
|
exit(1)
|
gibson/command/Tree.py
CHANGED
@@ -5,7 +5,8 @@ from .BaseCommand import BaseCommand
|
|
5
5
|
|
6
6
|
class Tree(BaseCommand):
|
7
7
|
def execute(self):
|
8
|
-
self.
|
8
|
+
self.configuration.ensure_project()
|
9
|
+
self.configuration.display_project()
|
9
10
|
|
10
11
|
if self.configuration.project.dev.base.path is None:
|
11
12
|
self.conversation.configure_dev_mode()
|
gibson/command/auth/Auth.py
CHANGED
@@ -18,9 +18,9 @@ class Auth(BaseCommand):
|
|
18
18
|
self.usage()
|
19
19
|
|
20
20
|
def usage(self):
|
21
|
-
self.
|
21
|
+
self.configuration.display_project()
|
22
22
|
self.conversation.type(
|
23
|
-
f"usage: {command(self.configuration.command)} {subcommand('auth')} {argument('login')} {hint('login to Gibson')}
|
23
|
+
f"usage: {command(self.configuration.command)} {subcommand('auth')} {argument('login')} {hint('login to Gibson')}\n"
|
24
24
|
)
|
25
25
|
self.conversation.type(
|
26
26
|
f" or: {command(self.configuration.command)} {subcommand('auth')} {argument('logout')} {hint('logout of Gibson')}\n"
|
@@ -37,12 +37,14 @@ class Rewrite(BaseCommand):
|
|
37
37
|
self.usage()
|
38
38
|
|
39
39
|
def write(self, argument=None):
|
40
|
+
self.configuration.ensure_project()
|
41
|
+
|
40
42
|
if len(self.memory.recall_merged()) == 0:
|
41
43
|
self.conversation.cant_no_entities(self.configuration.project.name)
|
42
44
|
exit(1)
|
43
45
|
|
44
46
|
if self.with_header is True:
|
45
|
-
self.
|
47
|
+
self.configuration.display_project()
|
46
48
|
|
47
49
|
customization_manager = CustomizationManager(self.configuration).preserve()
|
48
50
|
|
@@ -113,9 +115,9 @@ class Rewrite(BaseCommand):
|
|
113
115
|
return self
|
114
116
|
|
115
117
|
def usage(self):
|
116
|
-
self.
|
118
|
+
self.configuration.display_project()
|
117
119
|
self.conversation.type(
|
118
|
-
f"usage: {command(self.configuration.command)} {subcommand('rewrite')} {hint('rewrite all code')}
|
120
|
+
f"usage: {command(self.configuration.command)} {subcommand('rewrite')} {hint('rewrite all code')}\n"
|
119
121
|
)
|
120
122
|
self.conversation.type(
|
121
123
|
f" or: {command(self.configuration.command)} {subcommand('rewrite')} {arguments(self.arguments)} {hint('rewrite only the specified code')}\n"
|
gibson/conf/Paths.py
CHANGED
gibson/core/Colors.py
CHANGED
gibson/core/CommandRouter.py
CHANGED
@@ -7,6 +7,7 @@ from gibson.command.Conf import Conf
|
|
7
7
|
from gibson.command.Count import Count
|
8
8
|
from gibson.command.Dev import Dev
|
9
9
|
from gibson.command.Forget import Forget
|
10
|
+
from gibson.command.Help import Help
|
10
11
|
from gibson.command.Import import Import
|
11
12
|
from gibson.command.List import List
|
12
13
|
from gibson.command.Merge import Merge
|
@@ -33,7 +34,6 @@ from gibson.command.WarGames import WarGames
|
|
33
34
|
from gibson.core.Configuration import Configuration
|
34
35
|
from gibson.core.Conversation import Conversation
|
35
36
|
from gibson.core.Env import Env
|
36
|
-
from gibson.core.Memory import Memory
|
37
37
|
|
38
38
|
|
39
39
|
class CommandRouter:
|
@@ -41,127 +41,9 @@ class CommandRouter:
|
|
41
41
|
self.configuration = configuration
|
42
42
|
self.conversation = Conversation()
|
43
43
|
|
44
|
-
def help(self, exit_code=0):
|
45
|
-
dev_off = "*"
|
46
|
-
dev_on = ""
|
47
|
-
if self.configuration.project.dev.active is True:
|
48
|
-
dev_off = ""
|
49
|
-
dev_on = "*"
|
50
|
-
|
51
|
-
commands = {
|
52
|
-
"auth": {
|
53
|
-
"description": "login | logout",
|
54
|
-
"memory": None,
|
55
|
-
},
|
56
|
-
"build": {
|
57
|
-
"description": "create the entities in the datastore",
|
58
|
-
"memory": "stored",
|
59
|
-
},
|
60
|
-
"code": {"description": "pair program", "memory": None},
|
61
|
-
"conf": {"description": "set a configuration variable", "memory": None},
|
62
|
-
"count": {
|
63
|
-
"description": "show the number of entities stored",
|
64
|
-
"memory": "last | stored",
|
65
|
-
},
|
66
|
-
"dev": {
|
67
|
-
"description": f"mode off{dev_off} | on{dev_on}",
|
68
|
-
"memory": None,
|
69
|
-
},
|
70
|
-
"forget": {
|
71
|
-
"description": "delete memory",
|
72
|
-
"memory": "all | last | stored",
|
73
|
-
},
|
74
|
-
"help": {"description": "for help", "memory": None},
|
75
|
-
"import": {
|
76
|
-
"description": "configure from a data source",
|
77
|
-
"memory": "stored",
|
78
|
-
},
|
79
|
-
"list": {
|
80
|
-
"description": "show the names of entities in your project",
|
81
|
-
"memory": None,
|
82
|
-
},
|
83
|
-
"merge": {
|
84
|
-
"description": "move last changes into project",
|
85
|
-
"memory": "last -> stored",
|
86
|
-
},
|
87
|
-
"model": {
|
88
|
-
"description": "write the model code for an entity",
|
89
|
-
"memory": "stored",
|
90
|
-
},
|
91
|
-
"modify": {
|
92
|
-
"description": "change an entity using natural language",
|
93
|
-
"memory": "last > stored",
|
94
|
-
},
|
95
|
-
"module": {"description": "create a new module", "memory": "last"},
|
96
|
-
"new": {"description": "start something new", "memory": None},
|
97
|
-
"openapi": {"description": "build from an OpenAPI spec", "memory": "last"},
|
98
|
-
"remove": {
|
99
|
-
"description": "remove an entity from the project",
|
100
|
-
"memory": "last > stored",
|
101
|
-
},
|
102
|
-
"rename": {
|
103
|
-
"description": "rename an entity",
|
104
|
-
"memory": "last > stored",
|
105
|
-
},
|
106
|
-
"rewrite": {
|
107
|
-
"description": "rewrite code",
|
108
|
-
"memory": "stored",
|
109
|
-
},
|
110
|
-
"schema": {
|
111
|
-
"description": "write the schema code for an entity",
|
112
|
-
"memory": "stored",
|
113
|
-
},
|
114
|
-
"show": {"description": "display an entity", "memory": "last > stored"},
|
115
|
-
"test": {
|
116
|
-
"description": "write the unit tests for an entity",
|
117
|
-
"memory": "stored",
|
118
|
-
},
|
119
|
-
"tree": {"description": "illustrate the project layout", "memory": None},
|
120
|
-
"? | q": {"description": "ask a question", "memory": None},
|
121
|
-
}
|
122
|
-
|
123
|
-
self.conversation.set_delay(0.001)
|
124
|
-
self.conversation.display_project(self.configuration.project.name)
|
125
|
-
self.conversation.type(f"usage: {self.configuration.command} [command]\n\n")
|
126
|
-
self.conversation.type(" command description" + " " * 40 + "memory\n")
|
127
|
-
self.conversation.type(" ------- -----------" + " " * 40 + "------\n")
|
128
|
-
|
129
|
-
for command, config in commands.items():
|
130
|
-
memory = ""
|
131
|
-
if config["memory"] is not None:
|
132
|
-
memory = f"[{config['memory']}]"
|
133
|
-
|
134
|
-
spaces = 61 - (8 + 2 + len(config["description"]))
|
135
|
-
|
136
|
-
self.conversation.type(
|
137
|
-
f"{command.rjust(8)}"
|
138
|
-
+ f" {config['description']}"
|
139
|
-
+ " " * spaces
|
140
|
-
+ f"{memory}\n"
|
141
|
-
)
|
142
|
-
|
143
|
-
self.conversation.newline()
|
144
|
-
self.conversation.type("memory:\n\n")
|
145
|
-
|
146
|
-
stats = Memory(self.configuration).stats()
|
147
|
-
self.conversation.type(
|
148
|
-
f"{str(stats['entities']['num']).rjust(8)}"
|
149
|
-
+ f" {stats['entities']['word']}"
|
150
|
-
+ " " * (43 if stats["entities"]["word"] == "entities" else 45)
|
151
|
-
+ "[stored]\n"
|
152
|
-
)
|
153
|
-
self.conversation.type(
|
154
|
-
f"{str(stats['last']['num']).rjust(8)}"
|
155
|
-
+ f" {stats['last']['word']}"
|
156
|
-
+ " " * (43 if stats["last"]["word"] == "entities" else 45)
|
157
|
-
+ "[last]\n\n"
|
158
|
-
)
|
159
|
-
|
160
|
-
exit(exit_code)
|
161
|
-
|
162
44
|
def run(self):
|
163
|
-
if len(sys.argv) == 1
|
164
|
-
self.
|
45
|
+
if len(sys.argv) == 1:
|
46
|
+
Help(self.configuration).execute()
|
165
47
|
return self
|
166
48
|
|
167
49
|
Env().verify(self.configuration)
|
@@ -181,6 +63,8 @@ class CommandRouter:
|
|
181
63
|
command = Dev(self.configuration)
|
182
64
|
elif sys.argv[1] == "forget":
|
183
65
|
command = Forget(self.configuration)
|
66
|
+
elif sys.argv[1] == "help":
|
67
|
+
command = Help(self.configuration)
|
184
68
|
elif sys.argv[1] == "import":
|
185
69
|
command = Import(self.configuration)
|
186
70
|
elif sys.argv[1] == "list":
|
@@ -219,4 +103,5 @@ class CommandRouter:
|
|
219
103
|
command = WarGames(self.configuration)
|
220
104
|
|
221
105
|
if command is None or command.execute() is False:
|
222
|
-
self.
|
106
|
+
Help(self.configuration).execute()
|
107
|
+
exit(1)
|