gibson-cli 0.5.2__tar.gz → 0.5.4__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 (127) hide show
  1. {gibson_cli-0.5.2/gibson_cli.egg-info → gibson_cli-0.5.4}/PKG-INFO +1 -1
  2. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/api/BaseApi.py +9 -1
  3. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/api/Cli.py +5 -12
  4. gibson_cli-0.5.4/gibson/api/ProjectApi.py +13 -0
  5. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Build.py +3 -3
  6. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Conf.py +4 -4
  7. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Count.py +3 -3
  8. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Dev.py +3 -3
  9. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Forget.py +3 -3
  10. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Import.py +5 -5
  11. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Merge.py +1 -1
  12. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Model.py +3 -3
  13. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Modify.py +3 -3
  14. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/OpenApi.py +3 -3
  15. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Question.py +6 -6
  16. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Remove.py +3 -3
  17. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Schema.py +3 -3
  18. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Show.py +10 -7
  19. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Test.py +3 -3
  20. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Tree.py +1 -1
  21. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Version.py +5 -8
  22. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/auth/Auth.py +3 -3
  23. gibson_cli-0.5.4/gibson/command/code/Code.py +26 -0
  24. gibson_cli-0.5.2/gibson/command/Code.py → gibson_cli-0.5.4/gibson/command/code/Entity.py +2 -20
  25. gibson_cli-0.5.2/gibson/command/List.py → gibson_cli-0.5.4/gibson/command/list/Entities.py +2 -15
  26. gibson_cli-0.5.4/gibson/command/list/List.py +27 -0
  27. gibson_cli-0.5.4/gibson/command/list/Projects.py +25 -0
  28. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/new/Module.py +8 -6
  29. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/new/New.py +4 -4
  30. gibson_cli-0.5.2/gibson/command/Rename.py → gibson_cli-0.5.4/gibson/command/rename/Entity.py +9 -21
  31. gibson_cli-0.5.4/gibson/command/rename/Rename.py +21 -0
  32. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/rewrite/Rewrite.py +4 -4
  33. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/core/CommandRouter.py +3 -8
  34. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/core/Configuration.py +22 -15
  35. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/core/Conversation.py +9 -2
  36. {gibson_cli-0.5.2 → gibson_cli-0.5.4/gibson_cli.egg-info}/PKG-INFO +1 -1
  37. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson_cli.egg-info/SOURCES.txt +8 -3
  38. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson_cli.egg-info/top_level.txt +1 -0
  39. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/pyproject.toml +1 -1
  40. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/.gitignore +0 -0
  41. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/.pre-commit-config.yaml +0 -0
  42. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/README.md +0 -0
  43. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/bin/build.sh +0 -0
  44. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/bin/release.sh +0 -0
  45. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/bin/gibson.py +0 -0
  46. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/BaseCommand.py +0 -0
  47. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/Help.py +0 -0
  48. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/WarGames.py +0 -0
  49. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/auth/Login.py +0 -0
  50. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/auth/Logout.py +0 -0
  51. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/new/Project.py +0 -0
  52. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/rewrite/Api.py +0 -0
  53. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/rewrite/Base.py +0 -0
  54. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/rewrite/Models.py +0 -0
  55. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/rewrite/Schemas.py +0 -0
  56. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/rewrite/Tests.py +0 -0
  57. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/tests/test_command_BaseCommand.py +0 -0
  58. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/command/tests/test_command_Conf.py +0 -0
  59. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Api.py +0 -0
  60. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Code.py +0 -0
  61. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Custom.py +0 -0
  62. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Datastore.py +0 -0
  63. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Dependencies.py +0 -0
  64. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Dev.py +0 -0
  65. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Frameworks.py +0 -0
  66. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Modeler.py +0 -0
  67. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Paths.py +0 -0
  68. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Platform.py +0 -0
  69. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Project.py +0 -0
  70. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/Version.py +0 -0
  71. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/dev/Api.py +0 -0
  72. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/dev/Base.py +0 -0
  73. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/dev/Model.py +0 -0
  74. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/dev/Schema.py +0 -0
  75. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/tests/test_conf_Dependencies.py +0 -0
  76. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/conf/tests/test_conf_Platform.py +0 -0
  77. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/core/Colors.py +0 -0
  78. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/core/Completions.py +0 -0
  79. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/core/Env.py +0 -0
  80. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/core/Memory.py +0 -0
  81. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/core/PythonPath.py +0 -0
  82. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/core/TimeKeeper.py +0 -0
  83. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/core/utils.py +0 -0
  84. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/data/bash-completion.tmpl +0 -0
  85. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/data/default-ref-table.tmpl +0 -0
  86. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/data/default-table.tmpl +0 -0
  87. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/db/TableExceptions.py +0 -0
  88. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/db/tests/test_db_TableExceptions.py +0 -0
  89. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/dev/Dev.py +0 -0
  90. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/display/Header.py +0 -0
  91. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/display/WorkspaceFooter.py +0 -0
  92. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/display/WorkspaceHeader.py +0 -0
  93. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/display/tests/test_display_Header.py +0 -0
  94. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/display/tests/test_display_WorkspaceFooter.py +0 -0
  95. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/display/tests/test_display_WorkspaceHeader.py +0 -0
  96. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/lang/Python.py +0 -0
  97. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/lang/tests/test_lang_Python.py +0 -0
  98. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/auth/Server.py +0 -0
  99. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/context/schema/DataDictionary.py +0 -0
  100. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/context/schema/EntityKeys.py +0 -0
  101. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/context/schema/Manager.py +0 -0
  102. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/context/schema/tests/test_code_context_schema_DataDictionary.py +0 -0
  103. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/context/schema/tests/test_code_context_schema_EntityKeys.py +0 -0
  104. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/context/schema/tests/test_code_context_schema_Manager.py +0 -0
  105. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/customization/Authenticator.py +0 -0
  106. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/customization/BaseCustomization.py +0 -0
  107. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/customization/CustomizationManager.py +0 -0
  108. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/customization/Index.py +0 -0
  109. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/customization/tests/test_code_customization_Authenticator.py +0 -0
  110. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/services/code/customization/tests/test_code_customization_BaseCustomization.py +0 -0
  111. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/structure/Entity.py +0 -0
  112. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/structure/constraints/ReferenceConstraint.py +0 -0
  113. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/structure/keys/ForeignKey.py +0 -0
  114. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/structure/keys/Index.py +0 -0
  115. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/structure/keys/IndexAttribute.py +0 -0
  116. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/structure/keys/tests/test_ForeignKey.py +0 -0
  117. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/structure/keys/tests/test_Index.py +0 -0
  118. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/structure/keys/tests/test_IndexAttribute.py +0 -0
  119. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/structure/testing.py +0 -0
  120. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/structure/tests/test_Entity.py +0 -0
  121. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/tests/test_Env.py +0 -0
  122. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/tests/test_Memory.py +0 -0
  123. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson/tests/test_utils.py +0 -0
  124. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson_cli.egg-info/dependency_links.txt +0 -0
  125. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/gibson_cli.egg-info/entry_points.txt +0 -0
  126. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/requirements.txt +0 -0
  127. {gibson_cli-0.5.2 → gibson_cli-0.5.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gibson-cli
3
- Version: 0.5.2
3
+ Version: 0.5.4
4
4
  Summary: Gibson Command Line Interface
5
5
  Author-email: GibsonAI <noc@gibsonai.com>
6
6
  Project-URL: Homepage, https://gibsonai.com/
@@ -25,7 +25,15 @@ class BaseApi:
25
25
  return r.json()
26
26
 
27
27
  def headers(self):
28
- raise NotImplementedError
28
+ headers = {
29
+ "X-Gibson-Client-ID": self.configuration.client_id(),
30
+ }
31
+
32
+ token = self.configuration.get_access_token()
33
+ if token is not None:
34
+ headers["Authorization"] = f"Bearer {token}"
35
+
36
+ return headers
29
37
 
30
38
  def post(self, endpoint, json: dict):
31
39
  r = requests.post(self.url(endpoint), headers=self.headers(), json=json)
@@ -1,16 +1,16 @@
1
+ from gibson.api.BaseApi import BaseApi
1
2
  from gibson.core.Configuration import Configuration
2
3
  from gibson.core.Memory import Memory
3
4
  from gibson.lang.Python import Python
4
5
 
5
- from .BaseApi import BaseApi
6
-
7
6
 
8
7
  class Cli(BaseApi):
9
8
  PREFIX = "cli"
10
9
 
11
10
  def __init__(self, configuration: Configuration):
12
11
  self.configuration = configuration
13
- self.configuration.ensure_project()
12
+ self.configuration.require_login()
13
+ self.configuration.require_project()
14
14
 
15
15
  def code_api(self):
16
16
  return self.post(
@@ -64,15 +64,8 @@ class Cli(BaseApi):
64
64
  ).json()
65
65
 
66
66
  def headers(self):
67
- headers = {
68
- "X-Gibson-Client-ID": self.configuration.client_id(),
69
- "X-Gibson-API-Key": self.configuration.project.api.key,
70
- }
71
-
72
- token = self.configuration.get_access_token()
73
- if token is not None:
74
- headers["Authorization"] = f"Bearer {token}"
75
-
67
+ headers = super().headers()
68
+ headers["X-Gibson-API-Key"] = self.configuration.project.api.key
76
69
  return headers
77
70
 
78
71
  def import_(self):
@@ -0,0 +1,13 @@
1
+ from gibson.api.BaseApi import BaseApi
2
+ from gibson.core.Configuration import Configuration
3
+
4
+
5
+ class ProjectApi(BaseApi):
6
+ PREFIX = "project"
7
+
8
+ def __init__(self, configuration: Configuration):
9
+ self.configuration = configuration
10
+ self.configuration.require_login()
11
+
12
+ def all_projects(self):
13
+ return self.get("all")["projects"]
@@ -3,8 +3,8 @@ import sys
3
3
  from sqlalchemy import create_engine
4
4
  from sqlalchemy.orm import sessionmaker
5
5
 
6
+ import gibson.core.Colors as Colors
6
7
  from gibson.command.BaseCommand import BaseCommand
7
- from gibson.core.Colors import argument, command, hint, subcommand
8
8
  from gibson.db.TableExceptions import TableExceptions
9
9
 
10
10
 
@@ -49,7 +49,7 @@ class Build(BaseCommand):
49
49
  if len(sys.argv) != 3 or sys.argv[2] != "datastore":
50
50
  self.usage()
51
51
 
52
- self.configuration.ensure_project()
52
+ self.configuration.require_project()
53
53
 
54
54
  if self.memory.entities is None or len(self.memory.entities) == 0:
55
55
  self.no_entities()
@@ -72,7 +72,7 @@ class Build(BaseCommand):
72
72
  else ""
73
73
  )
74
74
  self.conversation.type(
75
- f"usage: {command(self.configuration.command)} {subcommand('build')} {argument('datastore')} {hint('build the datastore')} {datastore_uri}\n"
75
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('build')} {Colors.argument('datastore')} {Colors.hint('build the datastore')} {datastore_uri}\n"
76
76
  )
77
77
  self.conversation.newline()
78
78
  exit(1)
@@ -1,7 +1,7 @@
1
1
  import sys
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.command.BaseCommand import BaseCommand
4
- from gibson.core.Colors import argument, command, hint, input, subcommand
5
5
 
6
6
 
7
7
  class Conf(BaseCommand):
@@ -39,7 +39,7 @@ class Conf(BaseCommand):
39
39
  except KeyError:
40
40
  self.usage()
41
41
 
42
- self.configuration.ensure_project()
42
+ self.configuration.require_project()
43
43
  self.configuration.display_project()
44
44
  self.conversation.type(f"{key}\n")
45
45
  self.conversation.type(f" [old value] {old_value}\n")
@@ -61,12 +61,12 @@ class Conf(BaseCommand):
61
61
  def usage(self):
62
62
  self.configuration.display_project()
63
63
  self.conversation.type(
64
- f"usage: {command(self.configuration.command)} {subcommand('conf')} {argument('[key]')} {input('[value]')} {hint('set a configuration value')}\n"
64
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('conf')} {Colors.argument('[key]')} {Colors.input('[value]')} {Colors.hint('set a configuration value')}\n"
65
65
  )
66
66
  self.conversation.newline()
67
67
 
68
68
  if self.configuration.project:
69
- self.conversation.type(f" where {argument('[key]')} is one of:\n")
69
+ self.conversation.type(f" where {Colors.argument('[key]')} is one of:\n")
70
70
  self.conversation.set_delay(0.004)
71
71
 
72
72
  for key in self.get_configuration_keys():
@@ -1,7 +1,7 @@
1
1
  import sys
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.command.BaseCommand import BaseCommand
4
- from gibson.core.Colors import arguments, command, hint, subcommand
5
5
 
6
6
 
7
7
  class Count(BaseCommand):
@@ -9,7 +9,7 @@ class Count(BaseCommand):
9
9
  if len(sys.argv) != 3 or sys.argv[2] not in ["last", "stored"]:
10
10
  self.usage()
11
11
 
12
- self.configuration.ensure_project()
12
+ self.configuration.require_project()
13
13
 
14
14
  if sys.argv[2] == "last":
15
15
  count = 0
@@ -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: {command(self.configuration.command)} {subcommand('count')} {arguments(['last', 'stored'])} {hint('display the number of entities')}\n"
34
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('count')} {Colors.arguments(['last', 'stored'])} {Colors.hint('display the number of entities')}\n"
35
35
  )
36
36
  self.conversation.newline()
37
37
  exit(1)
@@ -1,8 +1,8 @@
1
1
  import os
2
2
  import sys
3
3
 
4
+ import gibson.core.Colors as Colors
4
5
  from gibson.command.BaseCommand import BaseCommand
5
- from gibson.core.Colors import arguments, command, hint, subcommand
6
6
  from gibson.lang.Python import Python
7
7
 
8
8
 
@@ -30,7 +30,7 @@ class Dev(BaseCommand):
30
30
  if len(sys.argv) != 3 or sys.argv[2] not in ["off", "on"]:
31
31
  self.usage()
32
32
 
33
- self.configuration.ensure_project()
33
+ self.configuration.require_project()
34
34
 
35
35
  if sys.argv[2] == "off":
36
36
  if self.configuration.project.dev.active is True:
@@ -119,7 +119,7 @@ class Dev(BaseCommand):
119
119
  def usage(self):
120
120
  self.configuration.display_project()
121
121
  self.conversation.type(
122
- f"usage: {command(self.configuration.command)} {subcommand('dev')} {arguments(['off', 'on'])} {hint('turn dev mode on or off')}\n"
122
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('dev')} {Colors.arguments(['off', 'on'])} {Colors.hint('turn dev mode on or off')}\n"
123
123
  )
124
124
  self.conversation.newline()
125
125
  exit(1)
@@ -1,7 +1,7 @@
1
1
  import sys
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.command.BaseCommand import BaseCommand
4
- from gibson.core.Colors import arguments, command, hint, subcommand
5
5
 
6
6
 
7
7
  class Forget(BaseCommand):
@@ -9,7 +9,7 @@ class Forget(BaseCommand):
9
9
  if len(sys.argv) != 3 or sys.argv[2] not in ["all", "last", "stored"]:
10
10
  self.usage()
11
11
 
12
- self.configuration.ensure_project()
12
+ self.configuration.require_project()
13
13
  self.configuration.display_project()
14
14
 
15
15
  if sys.argv[2] in ["all", "last"]:
@@ -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: {command(self.configuration.command)} {subcommand('forget')} {arguments(['all', 'last', 'stored'])} {hint('delete entities from memory')}\n"
30
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('forget')} {Colors.arguments(['all', 'last', 'stored'])} {Colors.hint('delete entities from memory')}\n"
31
31
  )
32
32
  self.conversation.newline()
33
33
  exit(1)
@@ -3,10 +3,10 @@ import sys
3
3
  from sqlalchemy import create_engine
4
4
  from sqlalchemy.orm import sessionmaker
5
5
 
6
+ import gibson.core.Colors as Colors
6
7
  from gibson.api.Cli import Cli
7
8
  from gibson.command.BaseCommand import BaseCommand
8
9
  from gibson.command.rewrite.Rewrite import Rewrite
9
- from gibson.core.Colors import argument, arguments, command, hint, option, subcommand
10
10
  from gibson.db.TableExceptions import TableExceptions
11
11
 
12
12
 
@@ -15,7 +15,7 @@ class Import(BaseCommand):
15
15
  if len(sys.argv) != 3 and len(sys.argv) != 5:
16
16
  self.usage()
17
17
 
18
- self.configuration.ensure_project()
18
+ self.configuration.require_project()
19
19
  write_code = False
20
20
  if len(sys.argv) == 5:
21
21
  if sys.argv[3] != ".." or sys.argv[4] != "dev":
@@ -106,13 +106,13 @@ class Import(BaseCommand):
106
106
  else ""
107
107
  )
108
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"
109
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('import')} {Colors.argument('api')} {Colors.hint('import all entities from your project created on GibsonAI.com')}\n"
110
110
  )
111
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"
112
+ f" or: {Colors.command(self.configuration.command)} {Colors.subcommand('import')} {Colors.argument('datastore')} {Colors.hint('import all entities from your local datastore')} {datastore_uri}\n"
113
113
  )
114
114
  self.conversation.type(
115
- f" or: {command(self.configuration.command)} {subcommand('import')} {arguments(['api', 'datastore'])} {option('.. dev')} {hint('have dev mode write all the code')}\n"
115
+ f" or: {Colors.command(self.configuration.command)} {Colors.subcommand('import')} {Colors.arguments(['api', 'datastore'])} {Colors.option('.. dev')} {Colors.hint('have dev mode write all the code')}\n"
116
116
  )
117
117
  self.conversation.newline()
118
118
  exit(1)
@@ -3,7 +3,7 @@ from gibson.command.BaseCommand import BaseCommand
3
3
 
4
4
  class Merge(BaseCommand):
5
5
  def execute(self):
6
- self.configuration.ensure_project()
6
+ self.configuration.require_project()
7
7
  self.configuration.display_project()
8
8
 
9
9
  if self.memory.last is None or "entities" not in self.memory.last:
@@ -1,8 +1,8 @@
1
1
  import sys
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.api.Cli import Cli
4
5
  from gibson.command.BaseCommand import BaseCommand
5
- from gibson.core.Colors import command, hint, input, subcommand
6
6
  from gibson.core.TimeKeeper import TimeKeeper
7
7
  from gibson.dev.Dev import Dev
8
8
 
@@ -12,7 +12,7 @@ class Model(BaseCommand):
12
12
  if len(sys.argv) != 3:
13
13
  self.usage()
14
14
 
15
- self.configuration.ensure_project()
15
+ self.configuration.require_project()
16
16
  entity = self.memory.recall_stored_entity(sys.argv[2])
17
17
  if entity is None:
18
18
  self.conversation.not_sure_no_entity(
@@ -35,7 +35,7 @@ class Model(BaseCommand):
35
35
  def usage(self):
36
36
  self.configuration.display_project()
37
37
  self.conversation.type(
38
- f"usage: {command(self.configuration.command)} {subcommand('model')} {input('[entity name]')} {hint('generate the model for an entity')}\n"
38
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('model')} {Colors.input('[entity name]')} {Colors.hint('generate the model for an entity')}\n"
39
39
  )
40
40
  self.conversation.newline()
41
41
  exit(1)
@@ -1,8 +1,8 @@
1
1
  import sys
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.api.Cli import Cli
4
5
  from gibson.command.BaseCommand import BaseCommand
5
- from gibson.core.Colors import argument, command, hint, input, subcommand
6
6
 
7
7
 
8
8
  class Modify(BaseCommand):
@@ -10,7 +10,7 @@ class Modify(BaseCommand):
10
10
  if len(sys.argv) < 4:
11
11
  self.usage()
12
12
 
13
- self.configuration.ensure_project()
13
+ self.configuration.require_project()
14
14
  entity = self.memory.recall_entity(sys.argv[2])
15
15
  if entity is None:
16
16
  self.conversation.not_sure_no_entity(
@@ -34,7 +34,7 @@ class Modify(BaseCommand):
34
34
  def usage(self):
35
35
  self.configuration.display_project()
36
36
  self.conversation.type(
37
- f"usage: {command(self.configuration.command)} {subcommand('modify')} {argument('[entity name]')} {input('[instructions]')} {hint('modify an entity with natural language instructions')}\n"
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"
38
38
  )
39
39
  self.conversation.newline()
40
40
  exit(1)
@@ -2,9 +2,9 @@ import json
2
2
  import re
3
3
  import sys
4
4
 
5
+ import gibson.core.Colors as Colors
5
6
  from gibson.api.Cli import Cli
6
7
  from gibson.command.BaseCommand import BaseCommand
7
- from gibson.core.Colors import command, hint, input, subcommand
8
8
 
9
9
 
10
10
  class OpenApi(BaseCommand):
@@ -31,7 +31,7 @@ class OpenApi(BaseCommand):
31
31
  if "paths" not in contents:
32
32
  self.unrecognized_format()
33
33
 
34
- self.configuration.ensure_project()
34
+ self.configuration.require_project()
35
35
  self.configuration.display_project()
36
36
 
37
37
  if contents.get("info", None) is not None:
@@ -135,7 +135,7 @@ class OpenApi(BaseCommand):
135
135
  def usage(self):
136
136
  self.configuration.display_project()
137
137
  self.conversation.type(
138
- f"usage: {command(self.configuration.command)} {subcommand('openapi')} {input('[file path]')} {hint('import entities from an OpenAPI spec file')}\n"
138
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('openapi')} {Colors.input('[file path]')} {Colors.hint('import entities from an OpenAPI spec file')}\n"
139
139
  )
140
140
  self.conversation.newline()
141
141
  exit(1)
@@ -1,9 +1,9 @@
1
1
  import os
2
2
  import sys
3
3
 
4
+ import gibson.core.Colors as Colors
4
5
  from gibson.api.Cli import Cli
5
6
  from gibson.command.BaseCommand import BaseCommand
6
- from gibson.core.Colors import argument, command, hint, input, subcommand
7
7
 
8
8
 
9
9
  class Question(BaseCommand):
@@ -15,7 +15,7 @@ class Question(BaseCommand):
15
15
  if len(sys.argv) < 3:
16
16
  self.usage()
17
17
 
18
- self.configuration.ensure_project()
18
+ self.configuration.require_project()
19
19
  instructions = ""
20
20
  has_file = False
21
21
  has_python = False
@@ -96,16 +96,16 @@ class Question(BaseCommand):
96
96
  def usage(self):
97
97
  self.configuration.display_project()
98
98
  self.conversation.type(
99
- f"usage: {command(self.configuration.command)} {subcommand('q')} {input('[instructions]')} {hint('ask a question or tell Gibson to do something using natural language')}\n"
99
+ 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"
100
100
  )
101
101
  self.conversation.type(
102
- f" use {argument(self.TOKEN_FILE+'[path]')} to import a file from the filesystem\n"
102
+ f" use {Colors.argument(self.TOKEN_FILE+'[path]')} to import a file from the filesystem\n"
103
103
  )
104
104
  self.conversation.type(
105
- f" use {argument(self.TOKEN_PYTHON+'[import]')} to import a file from PYTHONPATH\n"
105
+ f" use {Colors.argument(self.TOKEN_PYTHON+'[import]')} to import a file from PYTHONPATH\n"
106
106
  )
107
107
  self.conversation.type(
108
- f" use {argument(self.TOKEN_SQL+'[entity name]')} to import SQL\n"
108
+ f" use {Colors.argument(self.TOKEN_SQL+'[entity name]')} to import SQL\n"
109
109
  )
110
110
 
111
111
  self.conversation.newline()
@@ -1,9 +1,9 @@
1
1
  import sys
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.api.Cli import Cli
4
5
  from gibson.command.BaseCommand import BaseCommand
5
6
  from gibson.command.rewrite.Rewrite import Rewrite
6
- from gibson.core.Colors import command, hint, input, subcommand
7
7
 
8
8
 
9
9
  class Remove(BaseCommand):
@@ -11,7 +11,7 @@ class Remove(BaseCommand):
11
11
  if len(sys.argv) != 3:
12
12
  self.usage()
13
13
 
14
- self.configuration.ensure_project()
14
+ self.configuration.require_project()
15
15
  self.configuration.display_project()
16
16
 
17
17
  found = False
@@ -74,7 +74,7 @@ class Remove(BaseCommand):
74
74
  def usage(self):
75
75
  self.configuration.display_project()
76
76
  self.conversation.type(
77
- f"usage: {command(self.configuration.command)} {subcommand('remove')} {input('[entity name]')} {hint('remove an entity from the project')}\n"
77
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('remove')} {Colors.input('[entity name]')} {Colors.hint('remove an entity from the project')}\n"
78
78
  )
79
79
  self.conversation.newline()
80
80
  exit(1)
@@ -1,8 +1,8 @@
1
1
  import sys
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.api.Cli import Cli
4
5
  from gibson.command.BaseCommand import BaseCommand
5
- from gibson.core.Colors import argument, command, hint, subcommand
6
6
  from gibson.core.TimeKeeper import TimeKeeper
7
7
  from gibson.dev.Dev import Dev
8
8
 
@@ -12,7 +12,7 @@ class Schema(BaseCommand):
12
12
  if len(sys.argv) != 3:
13
13
  self.usage()
14
14
 
15
- self.configuration.ensure_project()
15
+ self.configuration.require_project()
16
16
  entity = self.memory.recall_stored_entity(sys.argv[2])
17
17
  if entity is None:
18
18
  self.conversation.not_sure_no_entity(
@@ -35,7 +35,7 @@ class Schema(BaseCommand):
35
35
  def usage(self):
36
36
  self.configuration.display_project()
37
37
  self.conversation.type(
38
- f"usage: {command(self.configuration.command)} {subcommand('schema')} {argument('[entity name]')} {hint('write the schema code for an entity')}\n"
38
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('schema')} {Colors.argument('[entity name]')} {Colors.hint('write the schema code for an entity')}\n"
39
39
  )
40
40
  self.conversation.newline()
41
41
  exit(1)
@@ -1,19 +1,19 @@
1
1
  import sys
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.command.BaseCommand import BaseCommand
4
- from gibson.core.Colors import argument, command, hint, subcommand
5
5
 
6
6
 
7
7
  class Show(BaseCommand):
8
8
  def execute(self):
9
9
  if len(sys.argv) == 2:
10
- self.configuration.ensure_project()
10
+ self.configuration.require_project()
11
11
  entities = self.memory.recall_merged()
12
12
  if entities is None:
13
13
  self.conversation.cant_no_entities(self.configuration.project.name)
14
14
  exit(1)
15
15
  elif len(sys.argv) == 3:
16
- self.configuration.ensure_project()
16
+ self.configuration.require_project()
17
17
  entity = self.memory.recall_entity(sys.argv[2])
18
18
  if entity is None:
19
19
  self.conversation.not_sure_no_entity(
@@ -25,16 +25,19 @@ class Show(BaseCommand):
25
25
  else:
26
26
  self.usage()
27
27
 
28
- for entity in entities:
29
- print(entity["definition"])
28
+ for entity in sorted(entities, key=lambda x: x["name"]):
29
+ statement = entity["definition"].replace(
30
+ entity["name"], Colors.argument(entity["name"])
31
+ )
32
+ print(f"\n{statement}")
30
33
 
31
34
  def usage(self):
32
35
  self.configuration.display_project()
33
36
  self.conversation.type(
34
- f"usage: {command(self.configuration.command)} {subcommand('show')} {hint('display the entire schema')}\n"
37
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('show')} {Colors.hint('display the entire schema')}\n"
35
38
  )
36
39
  self.conversation.type(
37
- f" or: {command(self.configuration.command)} {subcommand('show')} {argument('[entity name]')} {hint('display the schema for an entity')}\n"
40
+ f" or: {Colors.command(self.configuration.command)} {Colors.subcommand('show')} {Colors.argument('[entity name]')} {Colors.hint('display the schema for an entity')}\n"
38
41
  )
39
42
  self.conversation.newline()
40
43
  exit(1)
@@ -1,8 +1,8 @@
1
1
  import sys
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.api.Cli import Cli
4
5
  from gibson.command.BaseCommand import BaseCommand
5
- from gibson.core.Colors import argument, command, hint, subcommand
6
6
  from gibson.core.TimeKeeper import TimeKeeper
7
7
  from gibson.dev.Dev import Dev
8
8
 
@@ -12,7 +12,7 @@ class Test(BaseCommand):
12
12
  if len(sys.argv) != 3:
13
13
  self.usage()
14
14
 
15
- self.configuration.ensure_project()
15
+ self.configuration.require_project()
16
16
  entity = self.memory.recall_stored_entity(sys.argv[2])
17
17
  if entity is None:
18
18
  self.conversation.not_sure_no_entity(
@@ -35,7 +35,7 @@ class Test(BaseCommand):
35
35
  def usage(self):
36
36
  self.configuration.display_project()
37
37
  self.conversation.type(
38
- f"usage: {command(self.configuration.command)} {subcommand('test')} {argument('[entity name]')} {hint('write the unit tests for an entity')}\n"
38
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('test')} {Colors.argument('[entity name]')} {Colors.hint('write the unit tests for an entity')}\n"
39
39
  )
40
40
  self.conversation.newline()
41
41
  exit(1)
@@ -5,7 +5,7 @@ from .BaseCommand import BaseCommand
5
5
 
6
6
  class Tree(BaseCommand):
7
7
  def execute(self):
8
- self.configuration.ensure_project()
8
+ self.configuration.require_project()
9
9
  self.configuration.display_project()
10
10
 
11
11
  if self.configuration.project.dev.base.path is None:
@@ -1,8 +1,8 @@
1
1
  import requests
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.command.BaseCommand import BaseCommand
4
5
  from gibson.conf.Version import Version as VersionConf
5
- from gibson.core.Colors import Color, colorize, command, option, subcommand
6
6
 
7
7
 
8
8
  class Version(BaseCommand):
@@ -15,18 +15,15 @@ class Version(BaseCommand):
15
15
 
16
16
  if latest_version != VersionConf.num:
17
17
  self.conversation.type(
18
- f"A new version of {command(self.configuration.command)} is available: {colorize(latest_version, Color.CYAN)}\n"
18
+ f"A new version of {Colors.command(self.configuration.command)} is available: {Colors.colorize(latest_version, Colors.Color.CYAN)}\n"
19
19
  )
20
20
  self.conversation.type(
21
- f"You are currently using version: {colorize(VersionConf.num, Color.VIOLET)}\n"
21
+ f"You are currently using version: {Colors.colorize(VersionConf.num, Colors.Color.VIOLET)}\n"
22
22
  )
23
23
  self.conversation.type(
24
- f"Please update to the latest version by running: {command('pip3')} {subcommand('install')} {option('--upgrade')} gibson-cli\n"
24
+ f"Please update to the latest version by running: {Colors.command('pip3')} {Colors.subcommand('install')} {Colors.option('--upgrade')} gibson-cli\n"
25
25
  )
26
26
  else:
27
27
  self.conversation.type(
28
- f"Nice! You are using the latest version of {command(self.configuration.command)}: {colorize(VersionConf.num, Color.CYAN)}\n"
28
+ f"Nice! 🎉 You are using the latest version of {Colors.command(self.configuration.command)}: {Colors.colorize(VersionConf.num, Colors.Color.CYAN)}\n"
29
29
  )
30
-
31
- self.conversation.newline()
32
- return True
@@ -1,9 +1,9 @@
1
1
  import sys
2
2
 
3
+ import gibson.core.Colors as Colors
3
4
  from gibson.command.auth.Login import Login
4
5
  from gibson.command.auth.Logout import Logout
5
6
  from gibson.command.BaseCommand import BaseCommand
6
- from gibson.core.Colors import argument, command, hint, subcommand
7
7
 
8
8
 
9
9
  class Auth(BaseCommand):
@@ -20,10 +20,10 @@ class Auth(BaseCommand):
20
20
  def usage(self):
21
21
  self.configuration.display_project()
22
22
  self.conversation.type(
23
- f"usage: {command(self.configuration.command)} {subcommand('auth')} {argument('login')} {hint('login to Gibson')}\n"
23
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('auth')} {Colors.argument('login')} {Colors.hint('login to Gibson')}\n"
24
24
  )
25
25
  self.conversation.type(
26
- f" or: {command(self.configuration.command)} {subcommand('auth')} {argument('logout')} {hint('logout of Gibson')}\n"
26
+ f" or: {Colors.command(self.configuration.command)} {Colors.subcommand('auth')} {Colors.argument('logout')} {Colors.hint('logout of Gibson')}\n"
27
27
  )
28
28
  self.conversation.newline()
29
29
  exit(1)
@@ -0,0 +1,26 @@
1
+ import sys
2
+
3
+ import gibson.core.Colors as Colors
4
+ from gibson.command.BaseCommand import BaseCommand
5
+ from gibson.command.code.Entity import Entity
6
+
7
+
8
+ class Code(BaseCommand):
9
+ def execute(self):
10
+ if len(sys.argv) == 4 and sys.argv[2] == "entity":
11
+ Entity(self.configuration).execute()
12
+ else:
13
+ self.usage()
14
+
15
+ def usage(self):
16
+ self.configuration.display_project()
17
+ self.conversation.type(
18
+ f"usage: {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('entity')} {Colors.input('[entity name]')} {Colors.hint('create a new entity')}\n"
19
+ )
20
+ self.conversation.newline()
21
+ self.conversation.type(
22
+ ' To create a new entity named "user":\n'
23
+ f" {Colors.command(self.configuration.command)} {Colors.subcommand('code')} {Colors.argument('entity')} {Colors.input('user')}\n"
24
+ )
25
+ self.conversation.newline()
26
+ exit(1)