gibson-cli 0.4.0__tar.gz → 0.5.1__tar.gz

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.
Files changed (123) hide show
  1. {gibson_cli-0.4.0/gibson_cli.egg-info → gibson_cli-0.5.1}/PKG-INFO +5 -3
  2. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/README.md +4 -2
  3. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/api/Cli.py +17 -1
  4. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Build.py +14 -4
  5. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Code.py +7 -7
  6. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Conf.py +14 -11
  7. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Count.py +6 -4
  8. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Dev.py +9 -4
  9. gibson_cli-0.5.1/gibson/command/Forget.py +33 -0
  10. gibson_cli-0.5.1/gibson/command/Help.py +125 -0
  11. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Import.py +18 -8
  12. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/List.py +7 -3
  13. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Merge.py +2 -4
  14. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Model.py +4 -4
  15. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Modify.py +4 -6
  16. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Module.py +5 -6
  17. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/New.py +3 -5
  18. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/OpenApi.py +8 -7
  19. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Question.py +16 -8
  20. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Remove.py +5 -4
  21. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Rename.py +5 -5
  22. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Schema.py +4 -4
  23. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Show.py +9 -6
  24. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Test.py +5 -5
  25. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Tree.py +2 -1
  26. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/auth/Auth.py +2 -2
  27. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/rewrite/Rewrite.py +5 -3
  28. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Paths.py +2 -0
  29. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/core/Colors.py +4 -0
  30. gibson_cli-0.5.1/gibson/core/CommandRouter.py +107 -0
  31. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/core/Configuration.py +74 -83
  32. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/core/Env.py +3 -0
  33. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/core/Memory.py +4 -3
  34. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/auth/Server.py +1 -1
  35. {gibson_cli-0.4.0 → gibson_cli-0.5.1/gibson_cli.egg-info}/PKG-INFO +5 -3
  36. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson_cli.egg-info/SOURCES.txt +1 -0
  37. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/pyproject.toml +1 -1
  38. gibson_cli-0.4.0/gibson/command/Forget.py +0 -34
  39. gibson_cli-0.4.0/gibson/core/CommandRouter.py +0 -222
  40. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/.gitignore +0 -0
  41. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/.pre-commit-config.yaml +0 -0
  42. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/bin/build.sh +0 -0
  43. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/bin/release.sh +0 -0
  44. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/api/BaseApi.py +0 -0
  45. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/bin/gibson.py +0 -0
  46. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/BaseCommand.py +0 -0
  47. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/Version.py +0 -0
  48. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/WarGames.py +0 -0
  49. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/auth/Login.py +0 -0
  50. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/auth/Logout.py +0 -0
  51. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/rewrite/Api.py +0 -0
  52. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/rewrite/Base.py +0 -0
  53. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/rewrite/Models.py +0 -0
  54. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/rewrite/Schemas.py +0 -0
  55. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/rewrite/Tests.py +0 -0
  56. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/tests/test_command_BaseCommand.py +0 -0
  57. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/command/tests/test_command_Conf.py +0 -0
  58. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Api.py +0 -0
  59. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Code.py +0 -0
  60. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Custom.py +0 -0
  61. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Datastore.py +0 -0
  62. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Dependencies.py +0 -0
  63. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Dev.py +0 -0
  64. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Frameworks.py +0 -0
  65. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Modeler.py +0 -0
  66. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Platform.py +0 -0
  67. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Project.py +0 -0
  68. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/Version.py +0 -0
  69. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/dev/Api.py +0 -0
  70. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/dev/Base.py +0 -0
  71. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/dev/Model.py +0 -0
  72. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/dev/Schema.py +0 -0
  73. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/tests/test_conf_Dependencies.py +0 -0
  74. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/conf/tests/test_conf_Platform.py +0 -0
  75. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/core/Completions.py +0 -0
  76. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/core/Conversation.py +0 -0
  77. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/core/PythonPath.py +0 -0
  78. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/core/TimeKeeper.py +0 -0
  79. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/core/utils.py +0 -0
  80. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/data/bash-completion.tmpl +0 -0
  81. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/data/default-ref-table.tmpl +0 -0
  82. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/data/default-table.tmpl +0 -0
  83. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/db/TableExceptions.py +0 -0
  84. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/db/tests/test_db_TableExceptions.py +0 -0
  85. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/dev/Dev.py +0 -0
  86. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/display/Header.py +0 -0
  87. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/display/WorkspaceFooter.py +0 -0
  88. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/display/WorkspaceHeader.py +0 -0
  89. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/display/tests/test_display_Header.py +0 -0
  90. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/display/tests/test_display_WorkspaceFooter.py +0 -0
  91. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/display/tests/test_display_WorkspaceHeader.py +0 -0
  92. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/lang/Python.py +0 -0
  93. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/lang/tests/test_lang_Python.py +0 -0
  94. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/context/schema/DataDictionary.py +0 -0
  95. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/context/schema/EntityKeys.py +0 -0
  96. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/context/schema/Manager.py +0 -0
  97. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/context/schema/tests/test_code_context_schema_DataDictionary.py +0 -0
  98. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/context/schema/tests/test_code_context_schema_EntityKeys.py +0 -0
  99. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/context/schema/tests/test_code_context_schema_Manager.py +0 -0
  100. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/customization/Authenticator.py +0 -0
  101. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/customization/BaseCustomization.py +0 -0
  102. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/customization/CustomizationManager.py +0 -0
  103. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/customization/Index.py +0 -0
  104. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/customization/tests/test_code_customization_Authenticator.py +0 -0
  105. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/services/code/customization/tests/test_code_customization_BaseCustomization.py +0 -0
  106. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/structure/Entity.py +0 -0
  107. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/structure/constraints/ReferenceConstraint.py +0 -0
  108. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/structure/keys/ForeignKey.py +0 -0
  109. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/structure/keys/Index.py +0 -0
  110. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/structure/keys/IndexAttribute.py +0 -0
  111. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/structure/keys/tests/test_ForeignKey.py +0 -0
  112. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/structure/keys/tests/test_Index.py +0 -0
  113. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/structure/keys/tests/test_IndexAttribute.py +0 -0
  114. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/structure/testing.py +0 -0
  115. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/structure/tests/test_Entity.py +0 -0
  116. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/tests/test_Env.py +0 -0
  117. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/tests/test_Memory.py +0 -0
  118. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson/tests/test_utils.py +0 -0
  119. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson_cli.egg-info/dependency_links.txt +0 -0
  120. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson_cli.egg-info/entry_points.txt +0 -0
  121. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/gibson_cli.egg-info/top_level.txt +0 -0
  122. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/requirements.txt +0 -0
  123. {gibson_cli-0.4.0 → gibson_cli-0.5.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gibson-cli
3
- Version: 0.4.0
3
+ Version: 0.5.1
4
4
  Summary: Gibson Command Line Interface
5
5
  Author-email: GibsonAI <noc@gibsonai.com>
6
6
  Project-URL: Homepage, https://gibsonai.com/
@@ -30,10 +30,12 @@ Gibson currently works on projects that use Python 3.9 or greater, MySQL, SQLAlc
30
30
 
31
31
  Portions of the Gibson backend code are written by Gibson. So far, versus a human developer, it has coded 66% of the software and did so in seconds. To get started, read the instructions here.
32
32
 
33
- ## Installation
33
+ ## Installation / Upgrading
34
+
35
+ Install the latest version of the CLI using pip.
34
36
 
35
37
  ```sh
36
- pip3 install gibson-cli
38
+ pip3 install gibson-cli --upgrade
37
39
  ```
38
40
 
39
41
  ## Key Terms
@@ -13,10 +13,12 @@ Gibson currently works on projects that use Python 3.9 or greater, MySQL, SQLAlc
13
13
 
14
14
  Portions of the Gibson backend code are written by Gibson. So far, versus a human developer, it has coded 66% of the software and did so in seconds. To get started, read the instructions here.
15
15
 
16
- ## Installation
16
+ ## Installation / Upgrading
17
+
18
+ Install the latest version of the CLI using pip.
17
19
 
18
20
  ```sh
19
- pip3 install gibson-cli
21
+ pip3 install gibson-cli --upgrade
20
22
  ```
21
23
 
22
24
  ## Key Terms
@@ -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,
@@ -105,6 +111,7 @@ class Cli(BaseApi):
105
111
  r = self.put(
106
112
  "modeler/entity/modify",
107
113
  {
114
+ "datastore": {"type": self.configuration.project.datastore.type},
108
115
  "entity": entity,
109
116
  "modeler": {"version": modeler_version},
110
117
  "modifications": modifications,
@@ -118,6 +125,7 @@ class Cli(BaseApi):
118
125
  r = self.put(
119
126
  "modeler/entity/remove",
120
127
  {
128
+ "datastore": {"type": self.configuration.project.datastore.type},
121
129
  "entity": {"name": entity_name},
122
130
  "modeler": {"version": modeler_version},
123
131
  "schema_": entities,
@@ -130,6 +138,7 @@ class Cli(BaseApi):
130
138
  r = self.put(
131
139
  "modeler/entity/rename",
132
140
  {
141
+ "datastore": {"type": self.configuration.project.datastore.type},
133
142
  "entity": {"current": current, "new": new},
134
143
  "modeler": {"version": modeler_version},
135
144
  "schema_": entities,
@@ -142,6 +151,7 @@ class Cli(BaseApi):
142
151
  r = self.post(
143
152
  "modeler/module",
144
153
  {
154
+ "datastore": {"type": self.configuration.project.datastore.type},
145
155
  "modeler": {"version": modeler_version},
146
156
  "module": module,
147
157
  "project": {"description": project_description},
@@ -161,7 +171,11 @@ class Cli(BaseApi):
161
171
  def modeler_reconcile(self, modeler_version, entities: list):
162
172
  r = self.post(
163
173
  "modeler/reconcile",
164
- {"modeler": {"version": modeler_version}, "schema_": entities},
174
+ {
175
+ "datastore": {"type": self.configuration.project.datastore.type},
176
+ "modeler": {"version": modeler_version},
177
+ "schema_": entities,
178
+ },
165
179
  )
166
180
 
167
181
  return r.json()
@@ -173,11 +187,13 @@ class Cli(BaseApi):
173
187
  with_stored=False,
174
188
  ):
175
189
  project_config = self.configuration.project
190
+
176
191
  payload = {
177
192
  "api": {
178
193
  "prefix": project_config.dev.api.prefix,
179
194
  "version": project_config.dev.api.version,
180
195
  },
196
+ "datastore": {"type": project_config.datastore.type},
181
197
  "frameworks": {
182
198
  "api": project_config.code.frameworks.api,
183
199
  "model": project_config.code.frameworks.model,
@@ -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.conversation.display_project(self.configuration.project.name)
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.conversation.display_project(self.configuration.project.name)
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.conversation.display_project(self.configuration.project.name)
66
- self.conversation.type(f"usage: {self.configuration.command} build datastore\n")
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)
@@ -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.conversation.display_project(self.configuration.project.name)
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.conversation.display_project(self.configuration.project.name)
189
+ self.configuration.display_project()
188
190
  self.conversation.type(
189
- f"usage: {self.configuration.command} code [thing] [name]\n"
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 called "user":\n'
196
- " gibson code entity user\n"
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)
@@ -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.conversation.display_project(self.configuration.project.name)
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.conversation.display_project(self.configuration.project.name)
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.set_delay(0.004)
66
+ self.conversation.newline()
66
67
 
67
- for key in self.get_configuration_keys():
68
- self.conversation.type(f" {key}\n")
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)
@@ -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.conversation.display_project(self.configuration.project.name)
32
+ self.configuration.display_project()
30
33
  self.conversation.type(
31
- f"usage: {self.configuration.command} count [which memory]\n"
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)
@@ -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.conversation.display_project(self.configuration.project.name)
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.conversation.display_project(self.configuration.project.name)
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.conversation.display_project(self.configuration.project.name)
118
- self.conversation.type(f"usage: {self.configuration.command} dev [off | on]\n")
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)
@@ -0,0 +1,33 @@
1
+ import sys
2
+
3
+ from gibson.command.BaseCommand import BaseCommand
4
+ from gibson.core.Colors import arguments, command, hint, subcommand
5
+
6
+
7
+ class Forget(BaseCommand):
8
+ def execute(self):
9
+ if len(sys.argv) != 3 or sys.argv[2] not in ["all", "last", "stored"]:
10
+ self.usage()
11
+
12
+ self.configuration.ensure_project()
13
+ self.configuration.display_project()
14
+
15
+ if sys.argv[2] in ["all", "last"]:
16
+ self.memory.forget_last()
17
+ self.conversation.type(f"last memory is forgotten.\n")
18
+
19
+ if sys.argv[2] in ["all", "stored"]:
20
+ self.memory.forget_entities()
21
+ self.conversation.type(f"stored memory is forgotten.\n")
22
+
23
+ self.conversation.newline()
24
+
25
+ return self
26
+
27
+ def usage(self):
28
+ self.configuration.display_project()
29
+ self.conversation.type(
30
+ f"usage: {command(self.configuration.command)} {subcommand('forget')} {arguments(['all', 'last', 'stored'])} {hint('delete entities from memory')}\n"
31
+ )
32
+ self.conversation.newline()
33
+ exit(1)
@@ -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
+ )
@@ -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.conversation.display_project(self.configuration.project.name)
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.conversation.display_project(self.configuration.project.name)
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.conversation.display_project(self.configuration.project.name)
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.conversation.display_project(self.configuration.project.name)
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"usage: {self.configuration.command} import [api | datastore] {{.. dev}}"
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)
@@ -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.conversation.display_project(self.configuration.project.name)
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.conversation.display_project(self.configuration.project.name)
58
- self.conversation.type(f"usage: {self.configuration.command} list entities\n")
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)
@@ -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.conversation.display_project(self.configuration.project.name)
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")
@@ -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.conversation.display_project(self.configuration.project.name)
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)
@@ -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.conversation.display_project(self.configuration.project.name)
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)