gibson-cli 0.4.0__py3-none-any.whl → 0.5.0__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 +16 -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.0.dist-info}/METADATA +5 -3
- {gibson_cli-0.4.0.dist-info → gibson_cli-0.5.0.dist-info}/RECORD +37 -36
- {gibson_cli-0.4.0.dist-info → gibson_cli-0.5.0.dist-info}/WHEEL +1 -1
- {gibson_cli-0.4.0.dist-info → gibson_cli-0.5.0.dist-info}/entry_points.txt +0 -0
- {gibson_cli-0.4.0.dist-info → gibson_cli-0.5.0.dist-info}/top_level.txt +0 -0
gibson/api/Cli.py
CHANGED
@@ -8,6 +8,10 @@ from .BaseApi import BaseApi
|
|
8
8
|
class Cli(BaseApi):
|
9
9
|
PREFIX = "cli"
|
10
10
|
|
11
|
+
def __init__(self, configuration: Configuration):
|
12
|
+
self.configuration = configuration
|
13
|
+
self.configuration.ensure_project()
|
14
|
+
|
11
15
|
def code_api(self):
|
12
16
|
return self.post(
|
13
17
|
"code/api",
|
@@ -76,6 +80,7 @@ class Cli(BaseApi):
|
|
76
80
|
|
77
81
|
def llm_query(self, instructions, has_file, has_python, has_sql):
|
78
82
|
project_config = self.configuration.project
|
83
|
+
|
79
84
|
r = self.post(
|
80
85
|
"llm/query",
|
81
86
|
{
|
@@ -86,6 +91,7 @@ class Cli(BaseApi):
|
|
86
91
|
"sql": int(has_sql),
|
87
92
|
}
|
88
93
|
},
|
94
|
+
"datastore": {"type": project_config.datastore.type},
|
89
95
|
"frameworks": {
|
90
96
|
"api": project_config.code.frameworks.api,
|
91
97
|
"model": project_config.code.frameworks.model,
|
@@ -118,6 +124,7 @@ class Cli(BaseApi):
|
|
118
124
|
r = self.put(
|
119
125
|
"modeler/entity/remove",
|
120
126
|
{
|
127
|
+
"datastore": {"type": self.configuration.project.datastore.type},
|
121
128
|
"entity": {"name": entity_name},
|
122
129
|
"modeler": {"version": modeler_version},
|
123
130
|
"schema_": entities,
|
@@ -130,6 +137,7 @@ class Cli(BaseApi):
|
|
130
137
|
r = self.put(
|
131
138
|
"modeler/entity/rename",
|
132
139
|
{
|
140
|
+
"datastore": {"type": self.configuration.project.datastore.type},
|
133
141
|
"entity": {"current": current, "new": new},
|
134
142
|
"modeler": {"version": modeler_version},
|
135
143
|
"schema_": entities,
|
@@ -142,6 +150,7 @@ class Cli(BaseApi):
|
|
142
150
|
r = self.post(
|
143
151
|
"modeler/module",
|
144
152
|
{
|
153
|
+
"datastore": {"type": self.configuration.project.datastore.type},
|
145
154
|
"modeler": {"version": modeler_version},
|
146
155
|
"module": module,
|
147
156
|
"project": {"description": project_description},
|
@@ -161,7 +170,11 @@ class Cli(BaseApi):
|
|
161
170
|
def modeler_reconcile(self, modeler_version, entities: list):
|
162
171
|
r = self.post(
|
163
172
|
"modeler/reconcile",
|
164
|
-
{
|
173
|
+
{
|
174
|
+
"datastore": {"type": self.configuration.project.datastore.type},
|
175
|
+
"modeler": {"version": modeler_version},
|
176
|
+
"schema_": entities,
|
177
|
+
},
|
165
178
|
)
|
166
179
|
|
167
180
|
return r.json()
|
@@ -173,11 +186,13 @@ class Cli(BaseApi):
|
|
173
186
|
with_stored=False,
|
174
187
|
):
|
175
188
|
project_config = self.configuration.project
|
189
|
+
|
176
190
|
payload = {
|
177
191
|
"api": {
|
178
192
|
"prefix": project_config.dev.api.prefix,
|
179
193
|
"version": project_config.dev.api.version,
|
180
194
|
},
|
195
|
+
"datastore": {"type": project_config.datastore.type},
|
181
196
|
"frameworks": {
|
182
197
|
"api": project_config.code.frameworks.api,
|
183
198
|
"model": project_config.code.frameworks.model,
|
gibson/command/Build.py
CHANGED
@@ -4,12 +4,13 @@ from sqlalchemy import create_engine
|
|
4
4
|
from sqlalchemy.orm import sessionmaker
|
5
5
|
|
6
6
|
from gibson.command.BaseCommand import BaseCommand
|
7
|
+
from gibson.core.Colors import argument, command, hint, subcommand
|
7
8
|
from gibson.db.TableExceptions import TableExceptions
|
8
9
|
|
9
10
|
|
10
11
|
class Build(BaseCommand):
|
11
12
|
def __build_datastore(self):
|
12
|
-
self.
|
13
|
+
self.configuration.display_project()
|
13
14
|
|
14
15
|
db = create_engine(self.configuration.project.datastore.uri)
|
15
16
|
session = sessionmaker(autocommit=False, autoflush=False, bind=db)()
|
@@ -48,13 +49,15 @@ class Build(BaseCommand):
|
|
48
49
|
if len(sys.argv) != 3 or sys.argv[2] != "datastore":
|
49
50
|
self.usage()
|
50
51
|
|
52
|
+
self.configuration.ensure_project()
|
53
|
+
|
51
54
|
if self.memory.entities is None or len(self.memory.entities) == 0:
|
52
55
|
self.no_entities()
|
53
56
|
|
54
57
|
self.__build_datastore()
|
55
58
|
|
56
59
|
def no_entities(self):
|
57
|
-
self.
|
60
|
+
self.configuration.display_project()
|
58
61
|
self.conversation.type(
|
59
62
|
"Ahhh man. I would love to but there aren't any entities.\n"
|
60
63
|
)
|
@@ -62,7 +65,14 @@ class Build(BaseCommand):
|
|
62
65
|
exit(1)
|
63
66
|
|
64
67
|
def usage(self):
|
65
|
-
self.
|
66
|
-
|
68
|
+
self.configuration.display_project()
|
69
|
+
datastore_uri = (
|
70
|
+
self.configuration.project.datastore.uri
|
71
|
+
if self.configuration.project
|
72
|
+
else ""
|
73
|
+
)
|
74
|
+
self.conversation.type(
|
75
|
+
f"usage: {command(self.configuration.command)} {subcommand('build')} {argument('datastore')} {hint('build the datastore')} {datastore_uri}\n"
|
76
|
+
)
|
67
77
|
self.conversation.newline()
|
68
78
|
exit(1)
|
gibson/command/Code.py
CHANGED
@@ -7,6 +7,7 @@ from gibson.api.Cli import Cli
|
|
7
7
|
from gibson.command.BaseCommand import BaseCommand
|
8
8
|
from gibson.command.Merge import Merge
|
9
9
|
from gibson.command.rewrite.Rewrite import Rewrite
|
10
|
+
from gibson.core.Colors import argument, command, hint, input, subcommand
|
10
11
|
from gibson.core.Configuration import Configuration
|
11
12
|
from gibson.display.Header import Header
|
12
13
|
from gibson.display.WorkspaceFooter import WorkspaceFooter
|
@@ -86,7 +87,8 @@ class Code(BaseCommand):
|
|
86
87
|
|
87
88
|
cli = Cli(self.configuration)
|
88
89
|
|
89
|
-
self.
|
90
|
+
self.configuration.ensure_project()
|
91
|
+
self.configuration.display_project()
|
90
92
|
definition = self.configure_definition()
|
91
93
|
|
92
94
|
self.conversation.c64_boot_search()
|
@@ -184,16 +186,14 @@ class Code(BaseCommand):
|
|
184
186
|
print(WorkspaceFooter().render())
|
185
187
|
|
186
188
|
def usage(self):
|
187
|
-
self.
|
189
|
+
self.configuration.display_project()
|
188
190
|
self.conversation.type(
|
189
|
-
f"usage: {self.configuration.command} code [
|
190
|
-
+ ' where [thing] can only be "entity", for now\n'
|
191
|
-
+ " and [name] is what you want [thing] to be called\n"
|
191
|
+
f"usage: {command(self.configuration.command)} {subcommand('code')} {argument('entity')} {input('[entity name]')} {hint('create a new entity')}\n"
|
192
192
|
)
|
193
193
|
self.conversation.newline()
|
194
194
|
self.conversation.type(
|
195
|
-
' To create a new entity
|
196
|
-
"
|
195
|
+
' To create a new entity named "user":\n'
|
196
|
+
f" {command(self.configuration.command)} {subcommand('code')} {argument('entity')} {input('user')}\n"
|
197
197
|
)
|
198
198
|
self.conversation.newline()
|
199
199
|
exit(1)
|
gibson/command/Conf.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import sys
|
2
2
|
|
3
3
|
from gibson.command.BaseCommand import BaseCommand
|
4
|
+
from gibson.core.Colors import argument, command, hint, input, subcommand
|
4
5
|
|
5
6
|
|
6
7
|
class Conf(BaseCommand):
|
@@ -38,7 +39,8 @@ class Conf(BaseCommand):
|
|
38
39
|
except KeyError:
|
39
40
|
self.usage()
|
40
41
|
|
41
|
-
self.
|
42
|
+
self.configuration.ensure_project()
|
43
|
+
self.configuration.display_project()
|
42
44
|
self.conversation.type(f"{key}\n")
|
43
45
|
self.conversation.type(f" [old value] {old_value}\n")
|
44
46
|
self.conversation.type(f" [new value] {value}\n")
|
@@ -57,18 +59,19 @@ class Conf(BaseCommand):
|
|
57
59
|
return configuration_keys
|
58
60
|
|
59
61
|
def usage(self):
|
60
|
-
self.
|
62
|
+
self.configuration.display_project()
|
61
63
|
self.conversation.type(
|
62
|
-
f"usage: {self.configuration.command} conf [key] [value]\n"
|
63
|
-
" where [key] is one of:\n"
|
64
|
+
f"usage: {command(self.configuration.command)} {subcommand('conf')} {argument('[key]')} {input('[value]')} {hint('set a configuration value')}\n"
|
64
65
|
)
|
65
|
-
self.conversation.
|
66
|
+
self.conversation.newline()
|
66
67
|
|
67
|
-
|
68
|
-
self.conversation.type(f"
|
68
|
+
if self.configuration.project:
|
69
|
+
self.conversation.type(f" where {argument('[key]')} is one of:\n")
|
70
|
+
self.conversation.set_delay(0.004)
|
71
|
+
|
72
|
+
for key in self.get_configuration_keys():
|
73
|
+
self.conversation.type(f" {key}\n")
|
74
|
+
|
75
|
+
self.conversation.newline()
|
69
76
|
|
70
|
-
self.conversation.newline()
|
71
|
-
self.conversation.type('"That was recursive! I used recursion, guys!"\n')
|
72
|
-
self.conversation.type(" -- Montero, 02/06/2024\n")
|
73
|
-
self.conversation.newline()
|
74
77
|
exit(1)
|
gibson/command/Count.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import sys
|
2
2
|
|
3
|
-
from .BaseCommand import BaseCommand
|
3
|
+
from gibson.command.BaseCommand import BaseCommand
|
4
|
+
from gibson.core.Colors import arguments, command, hint, subcommand
|
4
5
|
|
5
6
|
|
6
7
|
class Count(BaseCommand):
|
@@ -8,6 +9,8 @@ class Count(BaseCommand):
|
|
8
9
|
if len(sys.argv) != 3 or sys.argv[2] not in ["last", "stored"]:
|
9
10
|
self.usage()
|
10
11
|
|
12
|
+
self.configuration.ensure_project()
|
13
|
+
|
11
14
|
if sys.argv[2] == "last":
|
12
15
|
count = 0
|
13
16
|
if self.memory.last is not None:
|
@@ -26,10 +29,9 @@ class Count(BaseCommand):
|
|
26
29
|
return self
|
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} count [
|
32
|
-
+ ' where [which memory] is one of "last" or "stored"\n'
|
34
|
+
f"usage: {command(self.configuration.command)} {subcommand('count')} {arguments(['last', 'stored'])} {hint('display the number of entities')}\n"
|
33
35
|
)
|
34
36
|
self.conversation.newline()
|
35
37
|
exit(1)
|
gibson/command/Dev.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2
2
|
import sys
|
3
3
|
|
4
4
|
from gibson.command.BaseCommand import BaseCommand
|
5
|
+
from gibson.core.Colors import arguments, command, hint, subcommand
|
5
6
|
from gibson.lang.Python import Python
|
6
7
|
|
7
8
|
|
@@ -29,13 +30,15 @@ class Dev(BaseCommand):
|
|
29
30
|
if len(sys.argv) != 3 or sys.argv[2] not in ["off", "on"]:
|
30
31
|
self.usage()
|
31
32
|
|
33
|
+
self.configuration.ensure_project()
|
34
|
+
|
32
35
|
if sys.argv[2] == "off":
|
33
36
|
if self.configuration.project.dev.active is True:
|
34
37
|
self.configuration.turn_dev_off()
|
35
38
|
|
36
39
|
self.off()
|
37
40
|
|
38
|
-
self.
|
41
|
+
self.configuration.display_project()
|
39
42
|
self.conversation.type(
|
40
43
|
"Leveling up. Nice! I need a little context to make sure I write "
|
41
44
|
+ "code\nin the correct place. Then I will need you to tell me "
|
@@ -108,13 +111,15 @@ class Dev(BaseCommand):
|
|
108
111
|
return self
|
109
112
|
|
110
113
|
def off(self):
|
111
|
-
self.
|
114
|
+
self.configuration.display_project()
|
112
115
|
self.conversation.type("Dev Mode is off!\n")
|
113
116
|
self.conversation.newline()
|
114
117
|
exit(1)
|
115
118
|
|
116
119
|
def usage(self):
|
117
|
-
self.
|
118
|
-
self.conversation.type(
|
120
|
+
self.configuration.display_project()
|
121
|
+
self.conversation.type(
|
122
|
+
f"usage: {command(self.configuration.command)} {subcommand('dev')} {arguments(['off', 'on'])} {hint('turn dev mode on or off')}\n"
|
123
|
+
)
|
119
124
|
self.conversation.newline()
|
120
125
|
exit(1)
|
gibson/command/Forget.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import sys
|
2
2
|
|
3
|
-
from .BaseCommand import BaseCommand
|
3
|
+
from gibson.command.BaseCommand import BaseCommand
|
4
|
+
from gibson.core.Colors import arguments, command, hint, subcommand
|
4
5
|
|
5
6
|
|
6
7
|
class Forget(BaseCommand):
|
@@ -8,27 +9,25 @@ class Forget(BaseCommand):
|
|
8
9
|
if len(sys.argv) != 3 or sys.argv[2] not in ["all", "last", "stored"]:
|
9
10
|
self.usage()
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
self.configuration.ensure_project()
|
13
|
+
self.configuration.display_project()
|
14
|
+
|
15
|
+
if sys.argv[2] in ["all", "last"]:
|
15
16
|
self.memory.forget_last()
|
16
|
-
|
17
|
+
self.conversation.type(f"last memory is forgotten.\n")
|
18
|
+
|
19
|
+
if sys.argv[2] in ["all", "stored"]:
|
17
20
|
self.memory.forget_entities()
|
18
|
-
|
19
|
-
raise NotImplementedError
|
21
|
+
self.conversation.type(f"stored memory is forgotten.\n")
|
20
22
|
|
21
|
-
self.conversation.display_project(self.configuration.project.name)
|
22
|
-
self.conversation.type("Yeah man, forgotten.\n")
|
23
23
|
self.conversation.newline()
|
24
24
|
|
25
25
|
return self
|
26
26
|
|
27
27
|
def usage(self):
|
28
|
-
self.
|
28
|
+
self.configuration.display_project()
|
29
29
|
self.conversation.type(
|
30
|
-
f"usage: {self.configuration.command} forget [
|
31
|
-
+ ' where [which memory] is one of "all", "last" or "stored"\n'
|
30
|
+
f"usage: {command(self.configuration.command)} {subcommand('forget')} {arguments(['all', 'last', 'stored'])} {hint('delete entities from memory')}\n"
|
32
31
|
)
|
33
32
|
self.conversation.newline()
|
34
33
|
exit(1)
|
gibson/command/Help.py
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
import gibson.core.Colors as Colors
|
2
|
+
from gibson.command.BaseCommand import BaseCommand
|
3
|
+
from gibson.core.Memory import Memory
|
4
|
+
|
5
|
+
|
6
|
+
class Help(BaseCommand):
|
7
|
+
def execute(self):
|
8
|
+
dev_off = ""
|
9
|
+
dev_on = ""
|
10
|
+
|
11
|
+
if self.configuration.project is not None:
|
12
|
+
dev_off = "*" if self.configuration.project.dev.active is False else ""
|
13
|
+
dev_on = "*" if self.configuration.project.dev.active is True else ""
|
14
|
+
|
15
|
+
subcommands = {
|
16
|
+
"auth": {
|
17
|
+
"description": "login | logout",
|
18
|
+
"memory": None,
|
19
|
+
},
|
20
|
+
"build": {
|
21
|
+
"description": "create the entities in the datastore",
|
22
|
+
"memory": "stored",
|
23
|
+
},
|
24
|
+
"code": {"description": "pair program", "memory": None},
|
25
|
+
"conf": {"description": "set a configuration variable", "memory": None},
|
26
|
+
"count": {
|
27
|
+
"description": "show the number of entities stored",
|
28
|
+
"memory": "last | stored",
|
29
|
+
},
|
30
|
+
"dev": {
|
31
|
+
"description": f"mode off{dev_off} | on{dev_on}",
|
32
|
+
"memory": None,
|
33
|
+
},
|
34
|
+
"forget": {
|
35
|
+
"description": "delete memory",
|
36
|
+
"memory": "all | last | stored",
|
37
|
+
},
|
38
|
+
"help": {"description": "for help", "memory": None},
|
39
|
+
"import": {
|
40
|
+
"description": "configure from a data source",
|
41
|
+
"memory": "stored",
|
42
|
+
},
|
43
|
+
"list": {
|
44
|
+
"description": "show the names of entities in your project",
|
45
|
+
"memory": None,
|
46
|
+
},
|
47
|
+
"merge": {
|
48
|
+
"description": "move last changes into project",
|
49
|
+
"memory": "last -> stored",
|
50
|
+
},
|
51
|
+
"model": {
|
52
|
+
"description": "write the model code for an entity",
|
53
|
+
"memory": "stored",
|
54
|
+
},
|
55
|
+
"modify": {
|
56
|
+
"description": "change an entity using natural language",
|
57
|
+
"memory": "last > stored",
|
58
|
+
},
|
59
|
+
"module": {"description": "create a new module", "memory": "last"},
|
60
|
+
"new": {"description": "start something new", "memory": None},
|
61
|
+
"openapi": {"description": "build from an OpenAPI spec", "memory": "last"},
|
62
|
+
"remove": {
|
63
|
+
"description": "remove an entity from the project",
|
64
|
+
"memory": "last > stored",
|
65
|
+
},
|
66
|
+
"rename": {
|
67
|
+
"description": "rename an entity",
|
68
|
+
"memory": "last > stored",
|
69
|
+
},
|
70
|
+
"rewrite": {
|
71
|
+
"description": "rewrite code",
|
72
|
+
"memory": "stored",
|
73
|
+
},
|
74
|
+
"schema": {
|
75
|
+
"description": "write the schema code for an entity",
|
76
|
+
"memory": "stored",
|
77
|
+
},
|
78
|
+
"show": {"description": "display an entity", "memory": "last > stored"},
|
79
|
+
"test": {
|
80
|
+
"description": "write the unit tests for an entity",
|
81
|
+
"memory": "stored",
|
82
|
+
},
|
83
|
+
"tree": {"description": "illustrate the project layout", "memory": None},
|
84
|
+
"? | q": {"description": "ask a question", "memory": None},
|
85
|
+
}
|
86
|
+
|
87
|
+
self.conversation.set_delay(0.001)
|
88
|
+
self.configuration.display_project()
|
89
|
+
self.conversation.type(
|
90
|
+
f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('[command]')}\n\n"
|
91
|
+
)
|
92
|
+
self.conversation.type(" command description" + " " * 40 + "memory\n")
|
93
|
+
self.conversation.type(" ------- -----------" + " " * 40 + "------\n")
|
94
|
+
|
95
|
+
for subcommand, config in subcommands.items():
|
96
|
+
memory = ""
|
97
|
+
if config["memory"] is not None:
|
98
|
+
memory = f"[{config['memory']}]"
|
99
|
+
|
100
|
+
spaces = 61 - (8 + 2 + len(config["description"]))
|
101
|
+
|
102
|
+
self.conversation.type(
|
103
|
+
f"{Colors.subcommand(subcommand.rjust(8))}"
|
104
|
+
+ f" {config['description']}"
|
105
|
+
+ " " * spaces
|
106
|
+
+ f"{Colors.hint(memory)}\n"
|
107
|
+
)
|
108
|
+
|
109
|
+
self.conversation.newline()
|
110
|
+
|
111
|
+
if self.configuration.project is not None:
|
112
|
+
self.conversation.type("memory:\n\n")
|
113
|
+
stats = Memory(self.configuration).stats()
|
114
|
+
self.conversation.type(
|
115
|
+
f"{str(stats['entities']['num']).rjust(8)}"
|
116
|
+
+ f" {stats['entities']['word']}"
|
117
|
+
+ " " * (43 if stats["entities"]["word"] == "entities" else 45)
|
118
|
+
+ "[stored]\n"
|
119
|
+
)
|
120
|
+
self.conversation.type(
|
121
|
+
f"{str(stats['last']['num']).rjust(8)}"
|
122
|
+
+ f" {stats['last']['word']}"
|
123
|
+
+ " " * (43 if stats["last"]["word"] == "entities" else 45)
|
124
|
+
+ "[last]\n\n"
|
125
|
+
)
|
gibson/command/Import.py
CHANGED
@@ -6,6 +6,7 @@ from sqlalchemy.orm import sessionmaker
|
|
6
6
|
from gibson.api.Cli import Cli
|
7
7
|
from gibson.command.BaseCommand import BaseCommand
|
8
8
|
from gibson.command.rewrite.Rewrite import Rewrite
|
9
|
+
from gibson.core.Colors import argument, arguments, command, hint, option, subcommand
|
9
10
|
from gibson.db.TableExceptions import TableExceptions
|
10
11
|
|
11
12
|
|
@@ -14,13 +15,14 @@ class Import(BaseCommand):
|
|
14
15
|
if len(sys.argv) != 3 and len(sys.argv) != 5:
|
15
16
|
self.usage()
|
16
17
|
|
18
|
+
self.configuration.ensure_project()
|
17
19
|
write_code = False
|
18
20
|
if len(sys.argv) == 5:
|
19
21
|
if sys.argv[3] != ".." or sys.argv[4] != "dev":
|
20
22
|
self.usage()
|
21
23
|
|
22
24
|
if self.configuration.project.dev.active is False:
|
23
|
-
self.
|
25
|
+
self.configuration.display_project()
|
24
26
|
self.conversation.type(
|
25
27
|
"Dude, seriously?! You have Dev Mode turned off. "
|
26
28
|
+ "Why would you do that?\n"
|
@@ -54,7 +56,7 @@ class Import(BaseCommand):
|
|
54
56
|
return True
|
55
57
|
|
56
58
|
def __import_from_api(self):
|
57
|
-
self.
|
59
|
+
self.configuration.display_project()
|
58
60
|
|
59
61
|
self.conversation.type("Connected to API...\n")
|
60
62
|
response = Cli(self.configuration).import_()
|
@@ -67,7 +69,7 @@ class Import(BaseCommand):
|
|
67
69
|
return response["project"]["entities"]
|
68
70
|
|
69
71
|
def __import_from_datastore(self):
|
70
|
-
self.
|
72
|
+
self.configuration.display_project()
|
71
73
|
|
72
74
|
db = create_engine(self.configuration.project.datastore.uri)
|
73
75
|
session = sessionmaker(autocommit=False, autoflush=False, bind=db)()
|
@@ -97,12 +99,20 @@ class Import(BaseCommand):
|
|
97
99
|
return entities
|
98
100
|
|
99
101
|
def usage(self):
|
100
|
-
self.
|
102
|
+
self.configuration.display_project()
|
103
|
+
datastore_uri = (
|
104
|
+
self.configuration.project.datastore.uri
|
105
|
+
if self.configuration.project
|
106
|
+
else ""
|
107
|
+
)
|
108
|
+
self.conversation.type(
|
109
|
+
f"usage: {command(self.configuration.command)} {subcommand('import')} {argument('api')} {hint('import all entities from your project created on GibsonAI.com')}\n"
|
110
|
+
)
|
111
|
+
self.conversation.type(
|
112
|
+
f" or: {command(self.configuration.command)} {subcommand('import')} {argument('datastore')} {hint('import all entities from your local datastore')} {datastore_uri}\n"
|
113
|
+
)
|
101
114
|
self.conversation.type(
|
102
|
-
f"
|
103
|
-
+ "\n api = the project stored in your API key on GibsonAI.com\n"
|
104
|
-
+ f" datastore = {self.configuration.project.datastore.uri}\n"
|
105
|
-
+ " {.. dev} have Dev Mode write all the code\n"
|
115
|
+
f" or: {command(self.configuration.command)} {subcommand('import')} {arguments(['api', 'datastore'])} {option('.. dev')} {hint('have dev mode write all the code')}\n"
|
106
116
|
)
|
107
117
|
self.conversation.newline()
|
108
118
|
exit(1)
|
gibson/command/List.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 arguments, command, hint, subcommand
|
5
6
|
|
6
7
|
|
7
8
|
class List(BaseCommand):
|
@@ -9,7 +10,8 @@ class List(BaseCommand):
|
|
9
10
|
if len(sys.argv) != 3:
|
10
11
|
self.usage()
|
11
12
|
|
12
|
-
self.
|
13
|
+
self.configuration.ensure_project()
|
14
|
+
self.configuration.display_project()
|
13
15
|
|
14
16
|
entities = {"last": [], "stored": []}
|
15
17
|
|
@@ -54,7 +56,9 @@ class List(BaseCommand):
|
|
54
56
|
self.conversation.newline()
|
55
57
|
|
56
58
|
def usage(self):
|
57
|
-
self.
|
58
|
-
self.conversation.type(
|
59
|
+
self.configuration.display_project()
|
60
|
+
self.conversation.type(
|
61
|
+
f"usage: {command(self.configuration.command)} {subcommand('list')} {arguments(['entities'])} {hint('list all entities')}\n"
|
62
|
+
)
|
59
63
|
self.conversation.newline()
|
60
64
|
exit(1)
|
gibson/command/Merge.py
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
import sys
|
2
|
-
|
3
|
-
from gibson.api.Cli import Cli
|
4
1
|
from gibson.command.BaseCommand import BaseCommand
|
5
2
|
|
6
3
|
|
7
4
|
class Merge(BaseCommand):
|
8
5
|
def execute(self):
|
9
|
-
self.
|
6
|
+
self.configuration.ensure_project()
|
7
|
+
self.configuration.display_project()
|
10
8
|
|
11
9
|
if self.memory.last is None or "entities" not in self.memory.last:
|
12
10
|
self.conversation.type("No bueno. There is nothing to merge.\n\n")
|
gibson/command/Model.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 command, hint, input, subcommand
|
5
6
|
from gibson.core.TimeKeeper import TimeKeeper
|
6
7
|
from gibson.dev.Dev import Dev
|
7
8
|
|
@@ -11,6 +12,7 @@ class Model(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 Model(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} model [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('model')} {input('[entity name]')} {hint('generate the model for an entity')}\n"
|
39
39
|
)
|
40
40
|
self.conversation.newline()
|
41
41
|
exit(1)
|
gibson/command/Modify.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, input, subcommand
|
5
6
|
|
6
7
|
|
7
8
|
class Modify(BaseCommand):
|
@@ -9,6 +10,7 @@ class Modify(BaseCommand):
|
|
9
10
|
if len(sys.argv) < 4:
|
10
11
|
self.usage()
|
11
12
|
|
13
|
+
self.configuration.ensure_project()
|
12
14
|
entity = self.memory.recall_entity(sys.argv[2])
|
13
15
|
if entity is None:
|
14
16
|
self.conversation.not_sure_no_entity(
|
@@ -30,13 +32,9 @@ class Modify(BaseCommand):
|
|
30
32
|
print(response["entities"][0]["definition"])
|
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} "
|
36
|
-
+ "modify [entity name] [instructions]\n"
|
37
|
-
+ " where [entity name] is one of the entities that exists in "
|
38
|
-
+ "this project\n"
|
39
|
-
+ " and [instructions] is natural language describing the changes\n"
|
37
|
+
f"usage: {command(self.configuration.command)} {subcommand('modify')} {argument('[entity name]')} {input('[instructions]')} {hint('modify an entity with natural language instructions')}\n"
|
40
38
|
)
|
41
39
|
self.conversation.newline()
|
42
40
|
exit(1)
|
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)
|