gibson-cli 0.2.0__tar.gz → 0.3.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 (120) hide show
  1. {gibson_cli-0.2.0/gibson_cli.egg-info → gibson_cli-0.3.1}/PKG-INFO +10 -10
  2. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/README.md +9 -9
  3. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Code.py +2 -2
  4. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Import.py +2 -2
  5. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Remove.py +2 -2
  6. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Rename.py +2 -2
  7. gibson_cli-0.3.1/gibson/command/Version.py +32 -0
  8. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/auth/Auth.py +5 -2
  9. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/auth/Login.py +0 -2
  10. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/auth/Logout.py +1 -0
  11. {gibson_cli-0.2.0/gibson/command → gibson_cli-0.3.1/gibson/command/rewrite}/Base.py +0 -5
  12. {gibson_cli-0.2.0/gibson/command → gibson_cli-0.3.1/gibson/command/rewrite}/Models.py +0 -4
  13. gibson_cli-0.3.1/gibson/command/rewrite/Rewrite.py +124 -0
  14. {gibson_cli-0.2.0/gibson/command → gibson_cli-0.3.1/gibson/command/rewrite}/Schemas.py +1 -5
  15. {gibson_cli-0.2.0/gibson/command → gibson_cli-0.3.1/gibson/command/rewrite}/Tests.py +1 -5
  16. gibson_cli-0.3.1/gibson/core/Colors.py +68 -0
  17. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/core/CommandRouter.py +8 -38
  18. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/core/Configuration.py +3 -6
  19. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/core/Memory.py +2 -2
  20. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/data/bash-completion.tmpl +1 -1
  21. {gibson_cli-0.2.0 → gibson_cli-0.3.1/gibson_cli.egg-info}/PKG-INFO +10 -10
  22. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson_cli.egg-info/SOURCES.txt +7 -6
  23. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/pyproject.toml +1 -1
  24. gibson_cli-0.2.0/gibson/command/Rewrite.py +0 -107
  25. gibson_cli-0.2.0/gibson/command/Version.py +0 -8
  26. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/.gitignore +0 -0
  27. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/.pre-commit-config.yaml +0 -0
  28. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/bin/build.sh +0 -0
  29. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/bin/release.sh +0 -0
  30. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/api/BaseApi.py +0 -0
  31. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/api/Cli.py +0 -0
  32. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/bin/gibson.py +0 -0
  33. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/BaseCommand.py +0 -0
  34. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Build.py +0 -0
  35. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Conf.py +0 -0
  36. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Count.py +0 -0
  37. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Dev.py +0 -0
  38. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Forget.py +0 -0
  39. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/List.py +0 -0
  40. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Merge.py +0 -0
  41. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Model.py +0 -0
  42. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Modify.py +0 -0
  43. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Module.py +0 -0
  44. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/New.py +0 -0
  45. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/OpenApi.py +0 -0
  46. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Question.py +0 -0
  47. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Schema.py +0 -0
  48. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Show.py +0 -0
  49. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Test.py +0 -0
  50. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/Tree.py +0 -0
  51. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/WarGames.py +0 -0
  52. {gibson_cli-0.2.0/gibson/command → gibson_cli-0.3.1/gibson/command/rewrite}/Api.py +0 -0
  53. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/tests/test_command_BaseCommand.py +0 -0
  54. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/command/tests/test_command_Conf.py +0 -0
  55. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Api.py +0 -0
  56. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Code.py +0 -0
  57. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Custom.py +0 -0
  58. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Datastore.py +0 -0
  59. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Dependencies.py +0 -0
  60. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Dev.py +0 -0
  61. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Frameworks.py +0 -0
  62. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Modeler.py +0 -0
  63. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Paths.py +0 -0
  64. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Platform.py +0 -0
  65. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Project.py +0 -0
  66. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/Version.py +0 -0
  67. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/dev/Api.py +0 -0
  68. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/dev/Base.py +0 -0
  69. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/dev/Model.py +0 -0
  70. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/dev/Schema.py +0 -0
  71. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/tests/test_conf_Dependencies.py +0 -0
  72. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/conf/tests/test_conf_Platform.py +0 -0
  73. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/core/Completions.py +0 -0
  74. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/core/Conversation.py +0 -0
  75. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/core/Env.py +0 -0
  76. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/core/TimeKeeper.py +0 -0
  77. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/core/utils.py +0 -0
  78. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/data/default-ref-table.tmpl +0 -0
  79. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/data/default-table.tmpl +0 -0
  80. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/db/TableExceptions.py +0 -0
  81. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/db/tests/test_db_TableExceptions.py +0 -0
  82. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/dev/Dev.py +0 -0
  83. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/display/Header.py +0 -0
  84. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/display/WorkspaceFooter.py +0 -0
  85. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/display/WorkspaceHeader.py +0 -0
  86. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/display/tests/test_display_Header.py +0 -0
  87. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/display/tests/test_display_WorkspaceFooter.py +0 -0
  88. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/display/tests/test_display_WorkspaceHeader.py +0 -0
  89. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/lang/Python.py +0 -0
  90. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/lang/tests/test_lang_Python.py +0 -0
  91. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/auth/Server.py +0 -0
  92. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/context/schema/DataDictionary.py +0 -0
  93. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/context/schema/EntityKeys.py +0 -0
  94. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/context/schema/Manager.py +0 -0
  95. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/context/schema/tests/test_code_context_schema_DataDictionary.py +0 -0
  96. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/context/schema/tests/test_code_context_schema_EntityKeys.py +0 -0
  97. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/context/schema/tests/test_code_context_schema_Manager.py +0 -0
  98. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/customization/Authenticator.py +0 -0
  99. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/customization/BaseCustomization.py +0 -0
  100. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/customization/CustomizationManager.py +0 -0
  101. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/customization/tests/test_code_customization_Authenticator.py +0 -0
  102. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/services/code/customization/tests/test_code_customization_BaseCustomization.py +0 -0
  103. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/structure/Entity.py +0 -0
  104. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/structure/constraints/ReferenceConstraint.py +0 -0
  105. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/structure/keys/ForeignKey.py +0 -0
  106. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/structure/keys/Index.py +0 -0
  107. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/structure/keys/IndexAttribute.py +0 -0
  108. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/structure/keys/tests/test_ForeignKey.py +0 -0
  109. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/structure/keys/tests/test_Index.py +0 -0
  110. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/structure/keys/tests/test_IndexAttribute.py +0 -0
  111. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/structure/testing.py +0 -0
  112. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/structure/tests/test_Entity.py +0 -0
  113. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/tests/test_Env.py +0 -0
  114. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/tests/test_Memory.py +0 -0
  115. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson/tests/test_utils.py +0 -0
  116. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson_cli.egg-info/dependency_links.txt +0 -0
  117. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson_cli.egg-info/entry_points.txt +0 -0
  118. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/gibson_cli.egg-info/top_level.txt +0 -0
  119. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/requirements.txt +0 -0
  120. {gibson_cli-0.2.0 → gibson_cli-0.3.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gibson-cli
3
- Version: 0.2.0
3
+ Version: 0.3.1
4
4
  Summary: Gibson Command Line Interface
5
5
  Author-email: GibsonAI <noc@gibsonai.com>
6
6
  Project-URL: Homepage, https://gibsonai.com/
@@ -67,7 +67,7 @@ Let's consider a more concrete example. You imported your datastore into the CLI
67
67
 
68
68
  So Gibson creates a new version of the user table containing a nickname column. This new table is stored in last memory. If you execute:
69
69
 
70
- `gibson models`
70
+ `gibson rewrite models`
71
71
 
72
72
  The CLI will write the code for what is sitting in last memory.
73
73
 
@@ -123,8 +123,8 @@ All of Gibson's configuration files and caches are stored in `$HOME/.gibson`. Us
123
123
  - `:command! -nargs=* Gibson r ! gibson <args>`
124
124
  - Open a file and execute commands:
125
125
  - `:Gibson module abc`
126
- - `:Gibson models`
127
- - `:Gibson schemas`
126
+ - `:Gibson rewrite models`
127
+ - `:Gibson rewrite schemas`
128
128
 
129
129
  ## Currently Supported Software
130
130
 
@@ -200,7 +200,7 @@ For example, you might provide class name = `MyBaseModel` and import path = `pro
200
200
 
201
201
  ### Writing the Base Code
202
202
 
203
- `gibson base`
203
+ `gibson rewrite base`
204
204
 
205
205
  ### Writing the Code for a Single Model
206
206
 
@@ -212,20 +212,20 @@ For example, you might provide class name = `MyBaseModel` and import path = `pro
212
212
 
213
213
  ### Writing the Code for All Models
214
214
 
215
- `gibson models`
215
+ `gibson rewrite models`
216
216
 
217
217
  ### Writing the Code for All Schemas
218
218
 
219
- `gibson schemas`
219
+ `gibson rewrite schemas`
220
220
 
221
221
  ### Adding a New Module to the Software Using AI
222
222
 
223
223
  - gibson module [module name]
224
224
  - e.g. gibson module user
225
225
  - Gibson will display the SQL tables it has generated as a result of your request. It will store these entities in its last memory.
226
- - gibson models
226
+ - `gibson rewrite models`
227
227
  - This will write the code for the entities it just created.
228
- - gibson merge
228
+ - `gibson merge`
229
229
  - This will merge the new entities into your project.
230
230
  - Note, at the moment Gibson does not build the tables into your datastore.
231
231
 
@@ -234,7 +234,7 @@ For example, you might provide class name = `MyBaseModel` and import path = `pro
234
234
  - `gibson modify [table name] [natural language request]`
235
235
  - e.g. `gibson modify my_table I want to add a new column called name and remove all of the columns related to email`
236
236
  - Gibson will display the modified SQL table and store it in its last memory.
237
- - `gibson models`
237
+ - `gibson rewrite models`
238
238
  - This will write the code for the modified entity.
239
239
  - `gibson merge`
240
240
  - This will merge the modified entity into your project.
@@ -50,7 +50,7 @@ Let's consider a more concrete example. You imported your datastore into the CLI
50
50
 
51
51
  So Gibson creates a new version of the user table containing a nickname column. This new table is stored in last memory. If you execute:
52
52
 
53
- `gibson models`
53
+ `gibson rewrite models`
54
54
 
55
55
  The CLI will write the code for what is sitting in last memory.
56
56
 
@@ -106,8 +106,8 @@ All of Gibson's configuration files and caches are stored in `$HOME/.gibson`. Us
106
106
  - `:command! -nargs=* Gibson r ! gibson <args>`
107
107
  - Open a file and execute commands:
108
108
  - `:Gibson module abc`
109
- - `:Gibson models`
110
- - `:Gibson schemas`
109
+ - `:Gibson rewrite models`
110
+ - `:Gibson rewrite schemas`
111
111
 
112
112
  ## Currently Supported Software
113
113
 
@@ -183,7 +183,7 @@ For example, you might provide class name = `MyBaseModel` and import path = `pro
183
183
 
184
184
  ### Writing the Base Code
185
185
 
186
- `gibson base`
186
+ `gibson rewrite base`
187
187
 
188
188
  ### Writing the Code for a Single Model
189
189
 
@@ -195,20 +195,20 @@ For example, you might provide class name = `MyBaseModel` and import path = `pro
195
195
 
196
196
  ### Writing the Code for All Models
197
197
 
198
- `gibson models`
198
+ `gibson rewrite models`
199
199
 
200
200
  ### Writing the Code for All Schemas
201
201
 
202
- `gibson schemas`
202
+ `gibson rewrite schemas`
203
203
 
204
204
  ### Adding a New Module to the Software Using AI
205
205
 
206
206
  - gibson module [module name]
207
207
  - e.g. gibson module user
208
208
  - Gibson will display the SQL tables it has generated as a result of your request. It will store these entities in its last memory.
209
- - gibson models
209
+ - `gibson rewrite models`
210
210
  - This will write the code for the entities it just created.
211
- - gibson merge
211
+ - `gibson merge`
212
212
  - This will merge the new entities into your project.
213
213
  - Note, at the moment Gibson does not build the tables into your datastore.
214
214
 
@@ -217,7 +217,7 @@ For example, you might provide class name = `MyBaseModel` and import path = `pro
217
217
  - `gibson modify [table name] [natural language request]`
218
218
  - e.g. `gibson modify my_table I want to add a new column called name and remove all of the columns related to email`
219
219
  - Gibson will display the modified SQL table and store it in its last memory.
220
- - `gibson models`
220
+ - `gibson rewrite models`
221
221
  - This will write the code for the modified entity.
222
222
  - `gibson merge`
223
223
  - This will merge the modified entity into your project.
@@ -6,7 +6,7 @@ from string import Template
6
6
  from gibson.api.Cli import Cli
7
7
  from gibson.command.BaseCommand import BaseCommand
8
8
  from gibson.command.Merge import Merge
9
- from gibson.command.Rewrite import Rewrite
9
+ from gibson.command.rewrite.Rewrite import Rewrite
10
10
  from gibson.core.Configuration import Configuration
11
11
  from gibson.display.Header import Header
12
12
  from gibson.display.WorkspaceFooter import WorkspaceFooter
@@ -129,7 +129,7 @@ class Code(BaseCommand):
129
129
  Merge(self.configuration).execute()
130
130
  self.conversation.unmute()
131
131
 
132
- Rewrite(self.configuration, wipe=False).execute()
132
+ Rewrite(self.configuration, wipe=False).write()
133
133
 
134
134
  self.conversation.newline()
135
135
 
@@ -5,7 +5,7 @@ from sqlalchemy.orm import sessionmaker
5
5
 
6
6
  from gibson.api.Cli import Cli
7
7
  from gibson.command.BaseCommand import BaseCommand
8
- from gibson.command.Rewrite import Rewrite
8
+ from gibson.command.rewrite.Rewrite import Rewrite
9
9
  from gibson.db.TableExceptions import TableExceptions
10
10
 
11
11
 
@@ -48,7 +48,7 @@ class Import(BaseCommand):
48
48
  self.conversation.newline()
49
49
 
50
50
  if write_code:
51
- Rewrite(self.configuration).execute()
51
+ Rewrite(self.configuration).write()
52
52
  self.conversation.newline()
53
53
 
54
54
  return True
@@ -2,7 +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.command.Rewrite import Rewrite
5
+ from gibson.command.rewrite.Rewrite import Rewrite
6
6
 
7
7
 
8
8
  class Remove(BaseCommand):
@@ -63,7 +63,7 @@ class Remove(BaseCommand):
63
63
  self.conversation.type(f"[Removed] {sys.argv[2]}\n")
64
64
  self.conversation.newline()
65
65
 
66
- Rewrite(self.configuration, header="Refactoring").execute()
66
+ Rewrite(self.configuration, header="Refactoring").write()
67
67
 
68
68
  self.conversation.newline()
69
69
 
@@ -2,7 +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.command.Rewrite import Rewrite
5
+ from gibson.command.rewrite.Rewrite import Rewrite
6
6
 
7
7
 
8
8
  class Rename(BaseCommand):
@@ -53,7 +53,7 @@ class Rename(BaseCommand):
53
53
  self.conversation.type(f"[Renamed] {sys.argv[2]} -> {sys.argv[3]}\n")
54
54
  self.conversation.newline()
55
55
 
56
- Rewrite(self.configuration, header="Refactoring").execute()
56
+ Rewrite(self.configuration, header="Refactoring").write()
57
57
 
58
58
  self.conversation.newline()
59
59
 
@@ -0,0 +1,32 @@
1
+ import requests
2
+
3
+ from gibson.command.BaseCommand import BaseCommand
4
+ from gibson.conf.Version import Version as VersionConf
5
+ from gibson.core.Colors import Color, colorize, command, option, subcommand
6
+
7
+
8
+ class Version(BaseCommand):
9
+ def execute(self):
10
+ try:
11
+ r = requests.get("https://pypi.org/pypi/gibson-cli/json")
12
+ latest_version = r.json()["info"]["version"]
13
+ except:
14
+ latest_version = VersionConf.num
15
+
16
+ if latest_version != VersionConf.num:
17
+ self.conversation.type(
18
+ f"A new version of {command(self.configuration.command)} is available: {colorize(latest_version, Color.CYAN)}\n"
19
+ )
20
+ self.conversation.type(
21
+ f"You are currently using version: {colorize(VersionConf.num, Color.VIOLET)}\n"
22
+ )
23
+ self.conversation.type(
24
+ f"Please update to the latest version by running: {command('pip3')} {subcommand('install')} {option('--upgrade')} gibson-cli\n"
25
+ )
26
+ else:
27
+ self.conversation.type(
28
+ f"Nice! You are using the latest version of {command(self.configuration.command)}: {colorize(VersionConf.num, Color.CYAN)}\n"
29
+ )
30
+
31
+ self.conversation.newline()
32
+ return True
@@ -3,6 +3,7 @@ import sys
3
3
  from gibson.command.auth.Login import Login
4
4
  from gibson.command.auth.Logout import Logout
5
5
  from gibson.command.BaseCommand import BaseCommand
6
+ from gibson.core.Colors import argument, command, hint, subcommand
6
7
 
7
8
 
8
9
  class Auth(BaseCommand):
@@ -18,8 +19,10 @@ class Auth(BaseCommand):
18
19
 
19
20
  def usage(self):
20
21
  self.conversation.type(
21
- f"usage: {self.configuration.command} auth login\n"
22
- + f" or: {self.configuration.command} auth logout\n"
22
+ f"usage: {command(self.configuration.command)} {subcommand('auth')} {argument('login')} {hint('login to Gibson')} \n"
23
+ )
24
+ self.conversation.type(
25
+ f" or: {command(self.configuration.command)} {subcommand('auth')} {argument('logout')} {hint('logout of Gibson')}\n"
23
26
  )
24
27
  self.conversation.newline()
25
28
  exit(1)
@@ -6,10 +6,8 @@ from gibson.services.auth.Server import Server as AuthServer
6
6
  class Login(BaseCommand):
7
7
  def execute(self):
8
8
  authenticated = self.configuration.login()
9
-
10
9
  if authenticated:
11
10
  self.conversation.message_login_success()
12
11
  else:
13
12
  self.conversation.message_login_failure()
14
-
15
13
  self.conversation.newline()
@@ -5,3 +5,4 @@ class Logout(BaseCommand):
5
5
  def execute(self):
6
6
  self.configuration.set_access_token(None)
7
7
  self.conversation.type(f"You are now logged out.")
8
+ self.conversation.newline()
@@ -6,11 +6,6 @@ from gibson.dev.Dev import Dev
6
6
 
7
7
  class Base(BaseCommand):
8
8
  def execute(self):
9
- entities = self.memory.recall_merged()
10
- if len(entities) == 0:
11
- self.conversation.cant_no_entities(self.configuration.project.name)
12
- exit(1)
13
-
14
9
  time_keeper = TimeKeeper()
15
10
  dev = Dev(self.configuration)
16
11
 
@@ -11,10 +11,6 @@ class Models(BaseCommand):
11
11
  for entity in self.memory.entities:
12
12
  entities.append(entity["name"])
13
13
 
14
- if len(entities) == 0:
15
- self.conversation.cant_no_entities(self.configuration.project.name)
16
- exit(1)
17
-
18
14
  time_keeper = TimeKeeper()
19
15
 
20
16
  cli = Cli(self.configuration)
@@ -0,0 +1,124 @@
1
+ import os
2
+ import shutil
3
+ import sys
4
+
5
+ from gibson.core.Colors import arguments, command, hint, subcommand
6
+ from gibson.core.Configuration import Configuration
7
+ from gibson.core.TimeKeeper import TimeKeeper
8
+ from gibson.services.code.customization.CustomizationManager import CustomizationManager
9
+
10
+ from ..BaseCommand import BaseCommand
11
+ from .Api import Api
12
+ from .Base import Base
13
+ from .Models import Models
14
+ from .Schemas import Schemas
15
+ from .Tests import Tests
16
+
17
+
18
+ class Rewrite(BaseCommand):
19
+ def __init__(
20
+ self,
21
+ configuration: Configuration,
22
+ header="Writing Code",
23
+ wipe=True,
24
+ with_header=False,
25
+ ):
26
+ super().__init__(configuration)
27
+ self.wipe = wipe
28
+ self.with_header = with_header
29
+ self.arguments = ["api", "base", "models", "schemas", "tests"]
30
+
31
+ def execute(self):
32
+ if len(sys.argv) != 3:
33
+ self.write()
34
+ elif sys.argv[2] in self.arguments:
35
+ self.write(sys.argv[2])
36
+ else:
37
+ self.usage()
38
+
39
+ def write(self, argument=None):
40
+ if len(self.memory.recall_merged()) == 0:
41
+ self.conversation.cant_no_entities(self.configuration.project.name)
42
+ exit(1)
43
+
44
+ if self.with_header is True:
45
+ self.conversation.display_project(self.configuration.project.name)
46
+
47
+ customization_manager = CustomizationManager(self.configuration).preserve()
48
+
49
+ try:
50
+ if self.wipe is True:
51
+ for root, dirs, files in os.walk(
52
+ os.path.expandvars(self.configuration.project.dev.base.path)
53
+ ):
54
+ for file in files:
55
+ os.unlink(os.path.join(root, file))
56
+
57
+ for dir_ in dirs:
58
+ shutil.rmtree(os.path.join(root, dir_))
59
+
60
+ self.conversation.type("Writing Code\n")
61
+
62
+ if argument is None or argument == "api":
63
+ time_keeper = TimeKeeper()
64
+ self.conversation.type(" API ")
65
+ self.conversation.mute()
66
+ # Disable customization management here so we don't process this twice (see finally block)
67
+ Api(self.configuration).disable_customization_management().execute()
68
+ self.conversation.unmute()
69
+ self.conversation.type(time_keeper.get_display())
70
+ self.conversation.newline()
71
+
72
+ if argument is None or argument == "base":
73
+ time_keeper = TimeKeeper()
74
+ self.conversation.type(" Base ")
75
+ self.conversation.mute()
76
+ Base(self.configuration).execute()
77
+ self.conversation.unmute()
78
+ self.conversation.type(time_keeper.get_display())
79
+ self.conversation.newline()
80
+
81
+ if argument is None or argument == "models":
82
+ time_keeper = TimeKeeper()
83
+ self.conversation.type(" Models ")
84
+ self.conversation.mute()
85
+ Models(self.configuration).execute()
86
+ self.conversation.unmute()
87
+ self.conversation.type(time_keeper.get_display())
88
+ self.conversation.newline()
89
+
90
+ if argument is None or argument == "schemas":
91
+ time_keeper = TimeKeeper()
92
+ self.conversation.type(" Schemas ")
93
+ self.conversation.mute()
94
+ Schemas(self.configuration).execute()
95
+ self.conversation.unmute()
96
+ self.conversation.type(time_keeper.get_display())
97
+ self.conversation.newline()
98
+
99
+ if argument is None or argument == "tests":
100
+ time_keeper = TimeKeeper()
101
+ self.conversation.type(" Tests ")
102
+ self.conversation.mute()
103
+ Tests(self.configuration).execute()
104
+ self.conversation.unmute()
105
+ self.conversation.type(time_keeper.get_display())
106
+ self.conversation.newline()
107
+ finally:
108
+ customization_manager.restore()
109
+
110
+ if self.with_header is True:
111
+ self.conversation.newline()
112
+
113
+ return self
114
+
115
+ def usage(self):
116
+ self.conversation.display_project(self.configuration.project.name)
117
+ self.conversation.type(
118
+ f"usage: {command(self.configuration.command)} {subcommand('rewrite')} {hint('rewrite all code')} \n"
119
+ )
120
+ self.conversation.type(
121
+ f" or: {command(self.configuration.command)} {subcommand('rewrite')} {arguments(self.arguments)} {hint('rewrite only the specified code')}\n"
122
+ )
123
+ self.conversation.newline()
124
+ exit(1)
@@ -1,7 +1,7 @@
1
1
  from gibson.api.Cli import Cli
2
- from gibson.dev.Dev import Dev
3
2
  from gibson.command.BaseCommand import BaseCommand
4
3
  from gibson.core.TimeKeeper import TimeKeeper
4
+ from gibson.dev.Dev import Dev
5
5
 
6
6
 
7
7
  class Schemas(BaseCommand):
@@ -11,10 +11,6 @@ class Schemas(BaseCommand):
11
11
  for entity in self.memory.entities:
12
12
  entities.append(entity["name"])
13
13
 
14
- if len(entities) == 0:
15
- self.conversation.cant_no_entities(self.configuration.project.name)
16
- exit(1)
17
-
18
14
  time_keeper = TimeKeeper()
19
15
 
20
16
  cli = Cli(self.configuration)
@@ -1,7 +1,7 @@
1
1
  from gibson.api.Cli import Cli
2
- from gibson.dev.Dev import Dev
3
2
  from gibson.command.BaseCommand import BaseCommand
4
3
  from gibson.core.TimeKeeper import TimeKeeper
4
+ from gibson.dev.Dev import Dev
5
5
 
6
6
 
7
7
  class Tests(BaseCommand):
@@ -11,10 +11,6 @@ class Tests(BaseCommand):
11
11
  for entity in self.memory.entities:
12
12
  entities.append(entity["name"])
13
13
 
14
- if len(entities) == 0:
15
- self.conversation.cant_no_entities(self.configuration.project.name)
16
- exit(1)
17
-
18
14
  time_keeper = TimeKeeper()
19
15
 
20
16
  cli = Cli(self.configuration)
@@ -0,0 +1,68 @@
1
+ class Color:
2
+ BLACK = "\033[30m"
3
+ BLACK_BG = "\033[40m"
4
+ BLINK = "\033[5m"
5
+ BLINK2 = "\033[6m"
6
+ BLUE = "\033[34m"
7
+ BLUE_BG = "\033[44m"
8
+ BLUE_BG2 = "\033[104m"
9
+ BLUE2 = "\033[94m"
10
+ BOLD = "\033[1m"
11
+ CYAN = "\033[36m"
12
+ CYAN_BG = "\033[46m"
13
+ CYAN_BG2 = "\033[106m"
14
+ CYAN2 = "\033[96m"
15
+ END = "\033[0m"
16
+ GREEN = "\033[32m"
17
+ GREEN_BG = "\033[42m"
18
+ GREEN_BG2 = "\033[102m"
19
+ GREEN2 = "\033[92m"
20
+ GREY = "\033[90m"
21
+ GREY_BG = "\033[100m"
22
+ ITALIC = "\033[3m"
23
+ RED = "\033[31m"
24
+ RED_BG = "\033[41m"
25
+ RED_BG2 = "\033[101m"
26
+ RED2 = "\033[91m"
27
+ SELECTED = "\033[7m"
28
+ UNDERLINE = "\033[4m"
29
+ VIOLET = "\033[35m"
30
+ VIOLET_BG = "\033[45m"
31
+ VIOLET_BG2 = "\033[105m"
32
+ VIOLET2 = "\033[95m"
33
+ WHITE = "\033[37m"
34
+ WHITE_BG = "\033[47m"
35
+ WHITE_BG2 = "\033[107m"
36
+ WHITE2 = "\033[97m"
37
+ YELLOW = "\033[33m"
38
+ YELLOW_BG = "\033[43m"
39
+ YELLOW_BG2 = "\033[103m"
40
+ YELLOW2 = "\033[93m"
41
+
42
+
43
+ def colorize(text, color):
44
+ return f"{color}{text}{Color.END}"
45
+
46
+
47
+ def command(text):
48
+ return colorize(text, Color.GREEN)
49
+
50
+
51
+ def subcommand(text):
52
+ return colorize(text, Color.YELLOW)
53
+
54
+
55
+ def argument(text):
56
+ return colorize(text, Color.VIOLET)
57
+
58
+
59
+ def arguments(list):
60
+ return f"[{'|'.join(map(lambda x: argument(x), list))}]"
61
+
62
+
63
+ def option(text):
64
+ return colorize(text, Color.CYAN)
65
+
66
+
67
+ def hint(text):
68
+ return colorize(text, Color.GREY)
@@ -1,8 +1,6 @@
1
1
  import sys
2
2
 
3
- from gibson.command.Api import Api
4
3
  from gibson.command.auth.Auth import Auth
5
- from gibson.command.Base import Base
6
4
  from gibson.command.Build import Build
7
5
  from gibson.command.Code import Code
8
6
  from gibson.command.Conf import Conf
@@ -13,7 +11,6 @@ from gibson.command.Import import Import
13
11
  from gibson.command.List import List
14
12
  from gibson.command.Merge import Merge
15
13
  from gibson.command.Model import Model
16
- from gibson.command.Models import Models
17
14
  from gibson.command.Modify import Modify
18
15
  from gibson.command.Module import Module
19
16
  from gibson.command.New import New
@@ -21,12 +18,15 @@ from gibson.command.OpenApi import OpenApi
21
18
  from gibson.command.Question import Question
22
19
  from gibson.command.Remove import Remove
23
20
  from gibson.command.Rename import Rename
24
- from gibson.command.Rewrite import Rewrite
21
+ from gibson.command.rewrite.Api import Api
22
+ from gibson.command.rewrite.Base import Base
23
+ from gibson.command.rewrite.Models import Models
24
+ from gibson.command.rewrite.Rewrite import Rewrite
25
+ from gibson.command.rewrite.Schemas import Schemas
26
+ from gibson.command.rewrite.Tests import Tests
25
27
  from gibson.command.Schema import Schema
26
- from gibson.command.Schemas import Schemas
27
28
  from gibson.command.Show import Show
28
29
  from gibson.command.Test import Test
29
- from gibson.command.Tests import Tests
30
30
  from gibson.command.Tree import Tree
31
31
  from gibson.command.Version import Version
32
32
  from gibson.command.WarGames import WarGames
@@ -49,18 +49,10 @@ class CommandRouter:
49
49
  dev_on = "*"
50
50
 
51
51
  commands = {
52
- "api": {
53
- "description": "write the API code for the project",
54
- "memory": "stored",
55
- },
56
52
  "auth": {
57
53
  "description": "login | logout",
58
54
  "memory": None,
59
55
  },
60
- "base": {
61
- "description": "write the base code for the project",
62
- "memory": "stored",
63
- },
64
56
  "build": {
65
57
  "description": "create the entities in the datastore",
66
58
  "memory": "stored",
@@ -96,10 +88,6 @@ class CommandRouter:
96
88
  "description": "write the model code for an entity",
97
89
  "memory": "stored",
98
90
  },
99
- "models": {
100
- "description": "write all the model code",
101
- "memory": "stored",
102
- },
103
91
  "modify": {
104
92
  "description": "change an entity using natural language",
105
93
  "memory": "last > stored",
@@ -116,26 +104,18 @@ class CommandRouter:
116
104
  "memory": "last > stored",
117
105
  },
118
106
  "rewrite": {
119
- "description": "rewrite all code from scratch",
107
+ "description": "rewrite code",
120
108
  "memory": "stored",
121
109
  },
122
110
  "schema": {
123
111
  "description": "write the schema code for an entity",
124
112
  "memory": "stored",
125
113
  },
126
- "schemas": {
127
- "description": "write all the schema code",
128
- "memory": "stored",
129
- },
130
114
  "show": {"description": "display an entity", "memory": "last > stored"},
131
115
  "test": {
132
116
  "description": "write the unit tests for an entity",
133
117
  "memory": "stored",
134
118
  },
135
- "tests": {
136
- "description": "write all the unit tests",
137
- "memory": "stored",
138
- },
139
119
  "tree": {"description": "illustrate the project layout", "memory": None},
140
120
  "? | q": {"description": "ask a question", "memory": None},
141
121
  }
@@ -187,12 +167,8 @@ class CommandRouter:
187
167
  Env().verify(self.configuration)
188
168
 
189
169
  command = None
190
- if sys.argv[1] == "api":
191
- command = Api(self.configuration)
192
- elif sys.argv[1] == "auth":
170
+ if sys.argv[1] == "auth":
193
171
  command = Auth(self.configuration)
194
- elif sys.argv[1] == "base":
195
- command = Base(self.configuration)
196
172
  elif sys.argv[1] == "build":
197
173
  command = Build(self.configuration)
198
174
  elif sys.argv[1] == "code":
@@ -213,8 +189,6 @@ class CommandRouter:
213
189
  command = Merge(self.configuration)
214
190
  elif sys.argv[1] == "model":
215
191
  command = Model(self.configuration)
216
- elif sys.argv[1] == "models":
217
- command = Models(self.configuration)
218
192
  elif sys.argv[1] == "modify":
219
193
  command = Modify(self.configuration)
220
194
  elif sys.argv[1] == "module":
@@ -231,14 +205,10 @@ class CommandRouter:
231
205
  command = Rewrite(self.configuration, with_header=True)
232
206
  elif sys.argv[1] == "schema":
233
207
  command = Schema(self.configuration)
234
- elif sys.argv[1] == "schemas":
235
- command = Schemas(self.configuration)
236
208
  elif sys.argv[1] == "show":
237
209
  command = Show(self.configuration)
238
210
  elif sys.argv[1] == "test":
239
211
  command = Test(self.configuration)
240
- elif sys.argv[1] == "tests":
241
- command = Tests(self.configuration)
242
212
  elif sys.argv[1] == "tree":
243
213
  command = Tree(self.configuration)
244
214
  elif sys.argv[1] in ["?", "q"]: