gibson-cli 0.7.5__tar.gz → 0.7.7__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 (145) hide show
  1. {gibson_cli-0.7.5/gibson_cli.egg-info → gibson_cli-0.7.7}/PKG-INFO +13 -4
  2. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/README.md +9 -1
  3. gibson_cli-0.7.7/bin/gibson +26 -0
  4. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/api/BaseApi.py +1 -1
  5. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/api/Cli.py +1 -1
  6. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Build.py +6 -6
  7. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Conf.py +1 -2
  8. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Count.py +1 -1
  9. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Dev.py +5 -8
  10. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Forget.py +1 -1
  11. gibson_cli-0.7.7/gibson/command/Help.py +176 -0
  12. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Modify.py +2 -4
  13. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Question.py +2 -4
  14. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Remove.py +2 -2
  15. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Show.py +3 -5
  16. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Version.py +1 -1
  17. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/auth/Auth.py +3 -3
  18. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/code/Code.py +10 -10
  19. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/code/Entity.py +10 -3
  20. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/code/Model.py +2 -4
  21. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/code/Schema.py +9 -8
  22. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/code/Test.py +1 -3
  23. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/importer/Import.py +8 -8
  24. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/importer/OpenApi.py +1 -1
  25. gibson_cli-0.7.7/gibson/command/list/Entities.py +39 -0
  26. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/list/List.py +3 -3
  27. gibson_cli-0.7.7/gibson/command/list/Projects.py +41 -0
  28. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/new/Module.py +2 -2
  29. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/new/New.py +4 -4
  30. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/rename/Rename.py +1 -1
  31. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/rewrite/Rewrite.py +1 -2
  32. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/Colors.py +34 -7
  33. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/CommandRouter.py +0 -1
  34. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/Configuration.py +8 -3
  35. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/Conversation.py +17 -24
  36. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/Memory.py +1 -0
  37. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/Spinner.py +8 -3
  38. {gibson_cli-0.7.5 → gibson_cli-0.7.7/gibson_cli.egg-info}/PKG-INFO +13 -4
  39. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson_cli.egg-info/SOURCES.txt +1 -1
  40. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson_cli.egg-info/requires.txt +2 -1
  41. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson_cli.egg-info/top_level.txt +0 -1
  42. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/pyproject.toml +1 -1
  43. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/requirements.txt +2 -1
  44. gibson_cli-0.7.5/gibson/command/Help.py +0 -111
  45. gibson_cli-0.7.5/gibson/command/WarGames.py +0 -34
  46. gibson_cli-0.7.5/gibson/command/list/Entities.py +0 -51
  47. gibson_cli-0.7.5/gibson/command/list/Projects.py +0 -31
  48. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/.gitignore +0 -0
  49. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/.pre-commit-config.yaml +0 -0
  50. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/bin/build.sh +0 -0
  51. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/bin/clean.sh +0 -0
  52. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/bin/release.sh +0 -0
  53. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/api/ProjectApi.py +0 -0
  54. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/bin/gibson.py +0 -0
  55. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/BaseCommand.py +0 -0
  56. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Merge.py +0 -0
  57. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/Tree.py +0 -0
  58. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/auth/Login.py +0 -0
  59. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/auth/Logout.py +0 -0
  60. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/code/Api.py +0 -0
  61. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/code/Base.py +0 -0
  62. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/code/Models.py +0 -0
  63. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/code/Schemas.py +0 -0
  64. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/code/Tests.py +0 -0
  65. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/new/Project.py +0 -0
  66. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/rename/Entity.py +0 -0
  67. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/tests/test_command_BaseCommand.py +0 -0
  68. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/command/tests/test_command_Conf.py +0 -0
  69. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Api.py +0 -0
  70. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Code.py +0 -0
  71. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Custom.py +0 -0
  72. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Datastore.py +0 -0
  73. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Dependencies.py +0 -0
  74. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Dev.py +0 -0
  75. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Frameworks.py +0 -0
  76. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Modeler.py +0 -0
  77. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Paths.py +0 -0
  78. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Platform.py +0 -0
  79. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Project.py +0 -0
  80. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/Version.py +0 -0
  81. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/dev/Api.py +0 -0
  82. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/dev/Base.py +0 -0
  83. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/dev/Model.py +0 -0
  84. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/dev/Schema.py +0 -0
  85. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/tests/test_conf_Dependencies.py +0 -0
  86. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/conf/tests/test_conf_Platform.py +0 -0
  87. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/Completions.py +0 -0
  88. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/Diff.py +0 -0
  89. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/Env.py +0 -0
  90. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/PythonPath.py +0 -0
  91. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/TimeKeeper.py +0 -0
  92. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/core/utils.py +0 -0
  93. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/data/bash-completion.tmpl +0 -0
  94. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/data/mysql/default-ref-table.tmpl +0 -0
  95. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/data/mysql/default-table.tmpl +0 -0
  96. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/data/postgresql/default-ref-table.tmpl +0 -0
  97. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/data/postgresql/default-table.tmpl +0 -0
  98. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/db/TableExceptions.py +0 -0
  99. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/db/tests/test_db_TableExceptions.py +0 -0
  100. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/dev/Dev.py +0 -0
  101. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/display/Header.py +0 -0
  102. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/display/WorkspaceFooter.py +0 -0
  103. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/display/WorkspaceHeader.py +0 -0
  104. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/display/tests/test_display_Header.py +0 -0
  105. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/display/tests/test_display_WorkspaceFooter.py +0 -0
  106. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/display/tests/test_display_WorkspaceHeader.py +0 -0
  107. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/lang/Python.py +0 -0
  108. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/lang/tests/test_lang_Python.py +0 -0
  109. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/auth/Server.py +0 -0
  110. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/context/schema/DataDictionary.py +0 -0
  111. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/context/schema/EntityKeys.py +0 -0
  112. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/context/schema/Manager.py +0 -0
  113. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/context/schema/tests/test_code_context_schema_DataDictionary.py +0 -0
  114. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/context/schema/tests/test_code_context_schema_EntityKeys.py +0 -0
  115. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/context/schema/tests/test_code_context_schema_Manager.py +0 -0
  116. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/customization/Authenticator.py +0 -0
  117. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/customization/BaseCustomization.py +0 -0
  118. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/customization/CustomizationManager.py +0 -0
  119. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/customization/Index.py +0 -0
  120. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/customization/tests/test_code_customization_Authenticator.py +0 -0
  121. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/services/code/customization/tests/test_code_customization_BaseCustomization.py +0 -0
  122. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/Entity.py +0 -0
  123. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/mysql/Entity.py +0 -0
  124. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/mysql/constraints/ReferenceConstraint.py +0 -0
  125. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/mysql/keys/ForeignKey.py +0 -0
  126. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/mysql/keys/Index.py +0 -0
  127. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/mysql/keys/IndexAttribute.py +0 -0
  128. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/mysql/keys/tests/test_structure_mysql_keys_ForeignKey.py +0 -0
  129. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/mysql/keys/tests/test_structure_mysql_keys_Index.py +0 -0
  130. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/mysql/keys/tests/test_structure_mysql_keys_IndexAttribute.py +0 -0
  131. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/mysql/testing.py +0 -0
  132. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/mysql/tests/test_structure_mysql_Entity.py +0 -0
  133. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/postgresql/Entity.py +0 -0
  134. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/postgresql/References.py +0 -0
  135. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/postgresql/table/ForeignKey.py +0 -0
  136. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/postgresql/table/tests/test_structure_postgresql_table_ForeignKey.py +0 -0
  137. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/postgresql/testing.py +0 -0
  138. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/postgresql/tests/test_structure_postgresql_Entity.py +0 -0
  139. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/structure/tests/test_structure_Entity.py +0 -0
  140. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/tests/test_Env.py +0 -0
  141. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/tests/test_Memory.py +0 -0
  142. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson/tests/test_utils.py +0 -0
  143. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson_cli.egg-info/dependency_links.txt +0 -0
  144. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/gibson_cli.egg-info/entry_points.txt +0 -0
  145. {gibson_cli-0.7.5 → gibson_cli-0.7.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: gibson-cli
3
- Version: 0.7.5
3
+ Version: 0.7.7
4
4
  Summary: Gibson Command Line Interface
5
5
  Author-email: GibsonAI <noc@gibsonai.com>
6
6
  Project-URL: Homepage, https://gibsonai.com/
@@ -50,12 +50,13 @@ Requires-Dist: python-dotenv==1.0.1
50
50
  Requires-Dist: python-multipart==0.0.9
51
51
  Requires-Dist: PyYAML==6.0.1
52
52
  Requires-Dist: requests==2.31.0
53
- Requires-Dist: rich==13.7.1
53
+ Requires-Dist: rich==13.9.2
54
54
  Requires-Dist: shellingham==1.5.4
55
55
  Requires-Dist: six==1.16.0
56
56
  Requires-Dist: sniffio==1.3.1
57
57
  Requires-Dist: SQLAlchemy==1.4.41
58
58
  Requires-Dist: starlette==0.37.2
59
+ Requires-Dist: textual==0.83.0
59
60
  Requires-Dist: tomli==2.0.1
60
61
  Requires-Dist: typer==0.12.3
61
62
  Requires-Dist: typing_extensions==4.9.0
@@ -84,12 +85,20 @@ Portions of the Gibson backend code are written by Gibson. So far, versus a hum
84
85
 
85
86
  ## Installation / Upgrading
86
87
 
87
- Install the latest version of the CLI using pip.
88
+ Install the latest version of the CLI using `pip`
88
89
 
89
90
  ```sh
90
91
  pip3 install gibson-cli --upgrade
91
92
  ```
92
93
 
94
+ Note: the first time you install any package from PyPI via `pip` that includes an executable, it is placed in a directory that is likely not in your `PATH`. There are a number of ways to do this, but one method is to run the following command:
95
+
96
+ ```sh
97
+ echo 'export PATH="$PATH:${$(which python3)%python3}"' >> ~/.zshrc # or ~/.bashrc
98
+ ```
99
+
100
+ You will only need to do this once.
101
+
93
102
  ## Key Terms
94
103
 
95
104
  - Dev Mode
@@ -15,12 +15,20 @@ Portions of the Gibson backend code are written by Gibson. So far, versus a hum
15
15
 
16
16
  ## Installation / Upgrading
17
17
 
18
- Install the latest version of the CLI using pip.
18
+ Install the latest version of the CLI using `pip`
19
19
 
20
20
  ```sh
21
21
  pip3 install gibson-cli --upgrade
22
22
  ```
23
23
 
24
+ Note: the first time you install any package from PyPI via `pip` that includes an executable, it is placed in a directory that is likely not in your `PATH`. There are a number of ways to do this, but one method is to run the following command:
25
+
26
+ ```sh
27
+ echo 'export PATH="$PATH:${$(which python3)%python3}"' >> ~/.zshrc # or ~/.bashrc
28
+ ```
29
+
30
+ You will only need to do this once.
31
+
24
32
  ## Key Terms
25
33
 
26
34
  - Dev Mode
@@ -0,0 +1,26 @@
1
+ #!/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # This file is identical to what pip creates when you install an executable package, but it adds a dev mode banner.
5
+ # To easily switch between dev mode and installed mode, add the following functions to your .zshrc or .bashrc:
6
+ #
7
+ # cli_dev_on() {
8
+ # export PATH="$HOME/src/gibson/cli/bin:$PATH"
9
+ # export PYTHONPATH="$HOME/src/gibson/cli:$PYTHONPATH"
10
+ # }
11
+ #
12
+ # cli_dev_off() {
13
+ # export PATH=${PATH#$HOME/src/gibson/cli/bin:}
14
+ # export PYTHONPATH=${PYTHONPATH#:$HOME/src/gibson/cli:}
15
+ # }
16
+
17
+ import re
18
+ import sys
19
+
20
+ from gibson.bin.gibson import main
21
+ from gibson.display.Header import Header
22
+
23
+ if __name__ == "__main__":
24
+ print(f"{Header().render('dev mode')}\n")
25
+ sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
26
+ sys.exit(main())
@@ -86,7 +86,7 @@ class BaseApi:
86
86
  def __raise_for_status(self, r):
87
87
  if r.status_code == 401:
88
88
  self.configuration.conversation.type(
89
- f"\nYou need to log in to continue. Please run {Colors.command('gibson')} {Colors.subcommand('auth')} {Colors.argument('login')} and then try again.\n"
89
+ f"\nYou need to log in to continue. Please run {Colors.command(self.configuration.command, 'auth', args='login')} and then try again.\n"
90
90
  )
91
91
  exit(1)
92
92
 
@@ -11,7 +11,7 @@ class Cli(BaseApi):
11
11
  self.configuration = configuration
12
12
  self.configuration.require_login()
13
13
  self.configuration.require_project()
14
- self.configuration.require_project_key()
14
+ self.configuration.require_project_key_or_id()
15
15
 
16
16
  def code_api(self):
17
17
  return self.post(
@@ -39,13 +39,13 @@ class Build(BaseCommand):
39
39
 
40
40
  for table in tables:
41
41
  if table not in table_exceptions:
42
- self.conversation.type(f" {table[0]}\n", delay=0.002)
42
+ self.conversation.type(f" {table[0]}\n")
43
43
  session.execute(f"drop table if exists {table[0]}")
44
44
 
45
45
  self.conversation.type(" building entities\n")
46
46
 
47
47
  for entity in self.memory.entities:
48
- self.conversation.type(f" {entity['name']}\n", delay=0.002)
48
+ self.conversation.type(f" {entity['name']}\n")
49
49
  session.execute(entity["definition"])
50
50
  finally:
51
51
  session.execute("set foreign_key_checks = 1")
@@ -61,7 +61,7 @@ class Build(BaseCommand):
61
61
  session.execute(
62
62
  """select table_name
63
63
  from information_schema.tables
64
- where table_schema = :table_schema""",
64
+ where table_schema = :table_schema and table_type = 'BASE TABLE'""",
65
65
  {"table_schema": schema},
66
66
  )
67
67
  )
@@ -70,7 +70,7 @@ class Build(BaseCommand):
70
70
  self.conversation.type(" dropping existing entities\n")
71
71
 
72
72
  for table in tables:
73
- self.conversation.type(f" {table[0]}\n", delay=0.002)
73
+ self.conversation.type(f" {table[0]}\n")
74
74
  session.execute(f"drop table if exists {schema}.{table[0]} cascade")
75
75
  session.commit()
76
76
 
@@ -88,7 +88,7 @@ class Build(BaseCommand):
88
88
  session.execute(definition)
89
89
  session.commit()
90
90
 
91
- self.conversation.type(f' {name.split(".")[-1]}\n', delay=0.002)
91
+ self.conversation.type(f' {name.split(".")[-1]}\n')
92
92
 
93
93
  remove.append(name)
94
94
  except sqlalchemy.exc.ProgrammingError:
@@ -124,7 +124,7 @@ class Build(BaseCommand):
124
124
  else ""
125
125
  )
126
126
  self.conversation.type(
127
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('build')} {Colors.argument('datastore')} {Colors.hint('build the datastore')} {datastore_uri}\n"
127
+ f"usage: {Colors.command(self.configuration.command, 'build', args='datastore', hint='build the datastore')} {datastore_uri}\n"
128
128
  )
129
129
  self.conversation.newline()
130
130
  exit(1)
@@ -61,13 +61,12 @@ class Conf(BaseCommand):
61
61
  def usage(self):
62
62
  self.configuration.display_project()
63
63
  self.conversation.type(
64
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('conf')} {Colors.argument('[key]')} {Colors.input('[value]')} {Colors.hint('set a configuration value')}\n"
64
+ f"usage: {Colors.command(self.configuration.command, 'conf', args='[key]', inputs='[value]', hint='set a configuration value')}\n"
65
65
  )
66
66
  self.conversation.newline()
67
67
 
68
68
  if self.configuration.project:
69
69
  self.conversation.type(f" where {Colors.argument('[key]')} is one of:\n")
70
- self.conversation.set_delay(0.004)
71
70
 
72
71
  for key in self.get_configuration_keys():
73
72
  self.conversation.type(f" {key}\n")
@@ -31,7 +31,7 @@ class Count(BaseCommand):
31
31
  def usage(self):
32
32
  self.configuration.display_project()
33
33
  self.conversation.type(
34
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('count')} {Colors.arguments(['last', 'stored'])} {Colors.hint('display the number of entities')}\n"
34
+ f"usage: {Colors.command(self.configuration.command, 'count', args=['last', 'stored'], hint='display the number of entities')}\n"
35
35
  )
36
36
  self.conversation.newline()
37
37
  exit(1)
@@ -72,16 +72,13 @@ class Dev(BaseCommand):
72
72
  except FileExistsError:
73
73
  pass
74
74
 
75
- self.conversation.type(
76
- "\n https://api.yourdomain.com/v1/-/sneakers GET\n", delay=0.002
77
- )
78
- self.conversation.type(" ^ ^\n", delay=0.002)
79
- self.conversation.type(" | |\n", delay=0.002)
80
- self.conversation.type(" version _| |\n", delay=0.002)
75
+ self.conversation.type("\n https://api.yourdomain.com/v1/-/sneakers GET\n")
76
+ self.conversation.type(" ^ ^\n")
77
+ self.conversation.type(" | |\n")
78
+ self.conversation.type(" version _| |\n")
81
79
  self.conversation.type(
82
80
  " |_ prefix (to isolate GibsonAI "
83
81
  + "API routes)\n\n",
84
- delay=0.002,
85
82
  )
86
83
  self.conversation.type(
87
84
  " It is OK if you are not sure about these. Just leave the defaults\n"
@@ -119,7 +116,7 @@ class Dev(BaseCommand):
119
116
  def usage(self):
120
117
  self.configuration.display_project()
121
118
  self.conversation.type(
122
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('dev')} {Colors.arguments(['off', 'on'])} {Colors.hint('turn dev mode on or off')}\n"
119
+ f"usage: {Colors.command(self.configuration.command, 'dev', args=['off', 'on'], hint='turn dev mode on or off')}\n"
123
120
  )
124
121
  self.conversation.newline()
125
122
  exit(1)
@@ -27,7 +27,7 @@ class Forget(BaseCommand):
27
27
  def usage(self):
28
28
  self.configuration.display_project()
29
29
  self.conversation.type(
30
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('forget')} {Colors.arguments(['all', 'last', 'stored'])} {Colors.hint('delete entities from memory')}\n"
30
+ f"usage: {Colors.command(self.configuration.command, 'forget', args=['all', 'last', 'stored'], hint='delete entities from memory')}\n"
31
31
  )
32
32
  self.conversation.newline()
33
33
  exit(1)
@@ -0,0 +1,176 @@
1
+ from rich import box
2
+ from rich.console import Console
3
+ from rich.table import Table
4
+ from rich.text import Text
5
+
6
+ import gibson.core.Colors as Colors
7
+ from gibson.command.BaseCommand import BaseCommand
8
+ from gibson.core.Memory import Memory
9
+
10
+
11
+ class Help(BaseCommand):
12
+ def execute(self):
13
+ dev_mode_text = []
14
+
15
+ if self.configuration.project is not None:
16
+ dev_mode = "on" if self.configuration.project.dev.active is True else "off"
17
+ dev_color = (
18
+ "green" if self.configuration.project.dev.active is True else "red"
19
+ )
20
+ dev_mode_text = [
21
+ "\n\ndev mode is turned ",
22
+ (dev_mode, f"bold {dev_color}"),
23
+ ]
24
+
25
+ subcommands = {
26
+ "auth": {
27
+ "description": "authenticate with the gibson cli",
28
+ "subcommands": ["login", "logout"],
29
+ "memory": None,
30
+ },
31
+ "build": {
32
+ "description": "create the entities in the datastore",
33
+ "subcommands": ["datastore"],
34
+ "memory": "stored",
35
+ },
36
+ "code": {
37
+ "description": "pair program with gibson",
38
+ "subcommands": ["api", "base", "entity", "models", "schemas", "tests"],
39
+ "memory": None,
40
+ },
41
+ "conf": {
42
+ "description": "set a configuration variable",
43
+ "subcommands": None,
44
+ "memory": None,
45
+ },
46
+ "count": {
47
+ "description": "show the number of entities stored",
48
+ "subcommands": ["last", "stored"],
49
+ "memory": "based on user selection",
50
+ },
51
+ "dev": {
52
+ "description": Text.assemble(
53
+ "gibson will automatically write code for you",
54
+ *dev_mode_text,
55
+ ),
56
+ "subcommands": ["on", "off"],
57
+ "memory": None,
58
+ },
59
+ "forget": {
60
+ "description": f"delete entities from memory",
61
+ "subcommands": ["all", "last", "stored"],
62
+ "memory": "based on user selection",
63
+ },
64
+ "help": {"description": "for help", "subcommands": None, "memory": None},
65
+ "import": {
66
+ "description": "import entities from a datasource",
67
+ "subcommands": ["api", "mysql", "pg_dump", "openapi"],
68
+ "memory": "stored",
69
+ },
70
+ "list": {
71
+ "description": "see a list of your entities or projects",
72
+ "subcommands": ["entities", "projects"],
73
+ "memory": None,
74
+ },
75
+ "merge": {
76
+ "description": "merge last memory (recent changes) into stored project memory",
77
+ "subcommands": None,
78
+ "memory": "last -> stored",
79
+ },
80
+ "modify": {
81
+ "description": "change an entity using natural language",
82
+ "subcommands": None,
83
+ "memory": "last > stored",
84
+ },
85
+ "new": {
86
+ "description": "create something new",
87
+ "subcommands": ["project", "module", "entity"],
88
+ "memory": None,
89
+ },
90
+ "remove": {
91
+ "description": "remove an entity from the project",
92
+ "subcommands": None,
93
+ "memory": "last > stored",
94
+ },
95
+ "rename": {
96
+ "description": "rename an entity",
97
+ "subcommands": ["entity"],
98
+ "memory": "last > stored",
99
+ },
100
+ "rewrite": {
101
+ "description": "rewrite all code",
102
+ "subcommands": None,
103
+ "memory": "stored",
104
+ },
105
+ "show": {
106
+ "description": "display an entity",
107
+ "subcommands": None,
108
+ "memory": "last > stored",
109
+ },
110
+ "tree": {
111
+ "description": "illustrate the project layout in a tree view",
112
+ "subcommands": None,
113
+ "memory": None,
114
+ },
115
+ "q": {
116
+ "description": "ask gibson a question using natural language",
117
+ "subcommands": None,
118
+ "memory": None,
119
+ },
120
+ }
121
+
122
+ self.configuration.display_project()
123
+
124
+ console = Console()
125
+
126
+ help = Table(
127
+ title=Text.assemble(
128
+ "usage: ",
129
+ (self.configuration.command, "green bold"),
130
+ (" [command]", "yellow bold"),
131
+ (" [subcommand]", "magenta bold"),
132
+ ),
133
+ header_style="bold",
134
+ box=box.ROUNDED,
135
+ expand=True,
136
+ leading=1,
137
+ )
138
+ help.add_column("command", style="yellow bold", header_style="yellow bold")
139
+ help.add_column("description")
140
+ help.add_column("subcommands", header_style="magenta")
141
+ help.add_column("memory affected", style="grey50", header_style="grey50")
142
+
143
+ for subcommand, config in subcommands.items():
144
+ help.add_row(
145
+ subcommand,
146
+ config["description"],
147
+ (
148
+ Text(" | ").join(
149
+ Text(x, style="magenta") for x in config["subcommands"]
150
+ )
151
+ if config["subcommands"]
152
+ else ""
153
+ ),
154
+ config["memory"] or "",
155
+ )
156
+
157
+ console.print(help)
158
+
159
+ self.conversation.newline()
160
+
161
+ if self.configuration.project:
162
+ stats = Memory(self.configuration).stats()
163
+ memory = Table(
164
+ title="Memory",
165
+ show_header=True,
166
+ header_style="bold",
167
+ box=box.ROUNDED,
168
+ expand=True,
169
+ )
170
+ memory.add_column("stored", style="green", header_style="green")
171
+ memory.add_column("last", style="yellow", header_style="yellow")
172
+ memory.add_row(
173
+ f"{stats['entities']['num']} {stats['entities']['word']}",
174
+ f"{stats['last']['num']} {stats['last']['word']}",
175
+ )
176
+ console.print(memory)
@@ -13,9 +13,7 @@ class Modify(BaseCommand):
13
13
  self.configuration.require_project()
14
14
  entity = self.memory.recall_entity(sys.argv[2])
15
15
  if entity is None:
16
- self.conversation.not_sure_no_entity(
17
- self.configuration.project.name, sys.argv[2]
18
- )
16
+ self.conversation.not_sure_no_entity(self.configuration, sys.argv[2])
19
17
  exit(1)
20
18
 
21
19
  cli = Cli(self.configuration)
@@ -34,7 +32,7 @@ class Modify(BaseCommand):
34
32
  def usage(self):
35
33
  self.configuration.display_project()
36
34
  self.conversation.type(
37
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('modify')} {Colors.argument('[entity name]')} {Colors.input('[instructions]')} {Colors.hint('modify an entity with natural language instructions')}\n"
35
+ f"usage: {Colors.command(self.configuration.command, 'modify', inputs=['[entity name]', '[instructions]'], hint='modify an entity with natural language instructions')}\n"
38
36
  )
39
37
  self.conversation.newline()
40
38
  exit(1)
@@ -57,9 +57,7 @@ class Question(BaseCommand):
57
57
 
58
58
  entity = self.memory.recall_entity(name)
59
59
  if entity is None:
60
- self.conversation.not_sure_no_entity(
61
- self.configuration.project.name, name
62
- )
60
+ self.conversation.not_sure_no_entity(self.configuration, name)
63
61
  exit(1)
64
62
 
65
63
  has_sql = True
@@ -93,7 +91,7 @@ class Question(BaseCommand):
93
91
  def usage(self):
94
92
  self.configuration.display_project()
95
93
  self.conversation.type(
96
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('q')} {Colors.input('[instructions]')} {Colors.hint('ask a question or tell Gibson to do something using natural language')}\n"
94
+ f"usage: {Colors.command(self.configuration.command, 'q', inputs='[instructions]', hint='ask a question or tell Gibson to do something using natural language')}\n"
97
95
  )
98
96
  self.conversation.type(
99
97
  f" use {Colors.argument(self.TOKEN_FILE+'[path]')} to import a file from the filesystem\n"
@@ -50,7 +50,7 @@ class Remove(BaseCommand):
50
50
 
51
51
  if not found:
52
52
  self.conversation.type(
53
- f'Nothing removed, did not find entity named "{sys.argv[2]}".\n'
53
+ f"Nothing removed, no entity named {Colors.entity(sys.argv[2])}.\n"
54
54
  )
55
55
  self.conversation.newline()
56
56
  return self
@@ -76,7 +76,7 @@ class Remove(BaseCommand):
76
76
  def usage(self):
77
77
  self.configuration.display_project()
78
78
  self.conversation.type(
79
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('remove')} {Colors.input('[entity name]')} {Colors.hint('remove an entity from the project')}\n"
79
+ f"usage: {Colors.command(self.configuration.command, 'remove', inputs='[entity name]', hint='remove an entity from the project')}\n"
80
80
  )
81
81
  self.conversation.newline()
82
82
  exit(1)
@@ -16,9 +16,7 @@ class Show(BaseCommand):
16
16
  self.configuration.require_project()
17
17
  entity = self.memory.recall_entity(sys.argv[2])
18
18
  if entity is None:
19
- self.conversation.not_sure_no_entity(
20
- self.configuration.project.name, sys.argv[2]
21
- )
19
+ self.conversation.not_sure_no_entity(self.configuration, sys.argv[2])
22
20
  exit(1)
23
21
 
24
22
  entities = [entity]
@@ -32,10 +30,10 @@ class Show(BaseCommand):
32
30
  def usage(self):
33
31
  self.configuration.display_project()
34
32
  self.conversation.type(
35
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('show')} {Colors.hint('display the entire schema')}\n"
33
+ f"usage: {Colors.command(self.configuration.command, 'show', hint='display the entire schema')}\n"
36
34
  )
37
35
  self.conversation.type(
38
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('show')} {Colors.argument('[entity name]')} {Colors.hint('display the schema for an entity')}\n"
36
+ f" {Colors.command(self.configuration.command, 'show', inputs='[entity name]', hint='display the schema for an entity')}\n"
39
37
  )
40
38
  self.conversation.newline()
41
39
  exit(1)
@@ -21,7 +21,7 @@ class Version(BaseCommand):
21
21
  f"You are currently using version: {Colors.violet(VersionConf.num)}\n"
22
22
  )
23
23
  self.conversation.type(
24
- f"Please update to the latest version by running: {Colors.command('pip3')} {Colors.subcommand('install')} {Colors.option('--upgrade')} gibson-cli\n"
24
+ f"Please update to the latest version by running: {Colors.command('pip3', 'install', args='--upgrade', inputs='gibson-cli')}\n"
25
25
  )
26
26
  else:
27
27
  self.conversation.type(
@@ -20,13 +20,13 @@ class Auth(BaseCommand):
20
20
  def usage(self):
21
21
  self.configuration.display_project()
22
22
  self.conversation.type(
23
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('auth')} {Colors.arguments(['login', 'logout'])}\n"
23
+ f"usage: {Colors.command(self.configuration.command, 'auth', args=['login', 'logout'])}\n"
24
24
  )
25
25
  self.conversation.type(
26
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('auth')} {Colors.argument('login')} {Colors.hint('login to Gibson')}\n"
26
+ f" {Colors.command(self.configuration.command, 'auth', args='login', hint='login to Gibson')}\n"
27
27
  )
28
28
  self.conversation.type(
29
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('auth')} {Colors.argument('logout')} {Colors.hint('logout of Gibson')}\n"
29
+ f" {Colors.command(self.configuration.command, 'auth', args='logout', hint='logout of Gibson')}\n"
30
30
  )
31
31
  self.conversation.newline()
32
32
  exit(1)
@@ -39,34 +39,34 @@ class Code(BaseCommand):
39
39
  def usage(self):
40
40
  self.configuration.display_project()
41
41
  self.conversation.type(
42
- f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.arguments(['api', 'base', 'entity', 'models', 'schemas', 'tests'])} {Colors.input('[entity name]')} {Colors.hint('write code')}\n"
42
+ f"usage: {Colors.command(self.configuration.command, 'code', args=['api', 'base', 'entity', 'models', 'schemas', 'tests'], inputs='[entity name]', hint='write code')}\n"
43
43
  )
44
44
  self.conversation.type(
45
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('api')} {Colors.hint('generate the API code')}\n"
45
+ f" {Colors.command(self.configuration.command, 'code', args='api', hint='generate the API code')}\n"
46
46
  )
47
47
  self.conversation.type(
48
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('base')} {Colors.hint('generate the base code')}\n"
48
+ f" {Colors.command(self.configuration.command, 'code', args='base', hint='generate the base code')}\n"
49
49
  )
50
50
  self.conversation.type(
51
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('entity')} {Colors.input('[entity name]')} {Colors.hint('create or update an entity using the AI pair programmer')}\n"
51
+ f" {Colors.command(self.configuration.command, 'code', args='entity', inputs='[entity name]', hint='create or update an entity using the AI pair programmer')}\n"
52
52
  )
53
53
  self.conversation.type(
54
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('models')} {Colors.hint('generate the models for all entities')}\n"
54
+ f" {Colors.command(self.configuration.command, 'code', args='models', hint='generate the models for all entities')}\n"
55
55
  )
56
56
  self.conversation.type(
57
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('models')} {Colors.input('[entity name]')} {Colors.hint('generate the model(s) for a single entity')}\n"
57
+ f" {Colors.command(self.configuration.command, 'code', args='models', inputs='[entity name]', hint='generate the model(s) for a single entity')}\n"
58
58
  )
59
59
  self.conversation.type(
60
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('schemas')} {Colors.hint('generate the schemas for all entities')}\n"
60
+ f" {Colors.command(self.configuration.command, 'code', args='schemas', hint='generate the schemas for all entities')}\n"
61
61
  )
62
62
  self.conversation.type(
63
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('schemas')} {Colors.input('[entity name]')} {Colors.hint('generate the schema(s) for a single entity')}\n"
63
+ f" {Colors.command(self.configuration.command, 'code', args='schemas', inputs='[entity name]', hint='generate the schema(s) for a single entity')}\n"
64
64
  )
65
65
  self.conversation.type(
66
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('tests')} {Colors.hint('generate the unit tests for all entities')}\n"
66
+ f" {Colors.command(self.configuration.command, 'code', args='tests', hint='generate the unit tests for all entities')}\n"
67
67
  )
68
68
  self.conversation.type(
69
- f" {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('tests')} {Colors.input('[entity name]')} {Colors.hint('generate the unit tests for a single entity')}\n"
69
+ f" {Colors.command(self.configuration.command, 'code', args='tests', inputs='[entity name]', hint='generate the unit tests for a single entity')}\n"
70
70
  )
71
71
  self.conversation.newline()
72
72
  exit(1)
@@ -7,6 +7,7 @@ from string import Template
7
7
  import gibson.core.Colors as Colors
8
8
  from gibson.api.Cli import Cli
9
9
  from gibson.command.BaseCommand import BaseCommand
10
+ from gibson.command.code.Base import Base
10
11
  from gibson.command.code.Model import Model
11
12
  from gibson.command.code.Schema import Schema
12
13
  from gibson.command.code.Test import Test
@@ -98,6 +99,7 @@ class Entity(BaseCommand):
98
99
  self.__render_workspace(
99
100
  original_entity,
100
101
  entity,
102
+ data["code"][0]["name"],
101
103
  original_model_code,
102
104
  data["code"][0]["definition"],
103
105
  )
@@ -126,12 +128,16 @@ class Entity(BaseCommand):
126
128
  Schema(self.configuration).execute(entity_name=entity.name)
127
129
  Test(self.configuration).execute(entity_name=entity.name)
128
130
 
131
+ if original_entity is None:
132
+ # We need to ensure the testing.py file is updated to import the new entity
133
+ Base(self.configuration).execute()
134
+
129
135
  self.conversation.unmute()
130
136
  self.conversation.type(
131
- f"\nAll code for the {Colors.violet(entity.name)} entity has been written 🎉\n\n"
137
+ f"\nAll code for the {Colors.entity(entity.name)} entity has been written 🎉\n\n"
132
138
  )
133
139
  exit()
134
- elif input_ == "":
140
+ elif input_ == "" or input_.startswith(":"):
135
141
  continue
136
142
 
137
143
  with ComputingSpinner():
@@ -182,6 +188,7 @@ class Entity(BaseCommand):
182
188
  self,
183
189
  original_entity: StructureEntity | None,
184
190
  entity: StructureEntity,
191
+ model_name: str,
185
192
  original_model_code: str | None,
186
193
  model_code: str,
187
194
  ):
@@ -208,7 +215,7 @@ class Entity(BaseCommand):
208
215
  print("")
209
216
  print(Header().render("Model", Colors.yellow))
210
217
  print("")
211
- print(Colors.model(model_code_diff, entity.name))
218
+ print(Colors.model(model_code_diff, model_name, entity.name))
212
219
  print(WorkspaceFooter().render())
213
220
 
214
221
  def template_definition(self, entity_name):
@@ -14,14 +14,12 @@ class Model(BaseCommand):
14
14
  self.configuration.require_project()
15
15
  entity = self.memory.recall_stored_entity(entity_name)
16
16
  if entity is None:
17
- self.conversation.not_sure_no_entity(
18
- self.configuration.project.name, entity_name
19
- )
17
+ self.conversation.not_sure_no_entity(self.configuration, entity_name)
20
18
  exit(1)
21
19
 
22
20
  time_keeper = TimeKeeper()
23
21
 
24
- with Spinner("Gibson is writing the models...", "Models written"):
22
+ with Spinner("Gibson is writing the model...", "Model written"):
25
23
  cli = Cli(self.configuration)
26
24
  response = cli.code_models([entity["name"]])
27
25
  Dev(self.configuration).model(