Skip to content

Commit c8110d9

Browse files
committed
Experimental private parameterization of Gptcmd shell class, subject to change
1 parent 3137e00 commit c8110d9

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

src/gptcmd/cli.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,10 +1764,11 @@ def _write_crash_dump(shell: Gptcmd, exc: Exception) -> Optional[str]:
17641764
shell._threads.pop(detached_key, None)
17651765

17661766

1767-
def main() -> bool:
1768-
"""
1769-
Setuptools requires a callable entry point to build an installable script
1770-
"""
1767+
class ExperimentalAPIWarning(Warning):
1768+
pass
1769+
1770+
1771+
def _run(shell_cls) -> bool:
17711772
parser = argparse.ArgumentParser()
17721773
parser.add_argument(
17731774
"path",
@@ -1806,7 +1807,17 @@ def main() -> bool:
18061807
config = ConfigManager.from_toml(args.config)
18071808
else:
18081809
config = None
1809-
shell = Gptcmd(config=config)
1810+
if shell_cls is not Gptcmd:
1811+
import warnings
1812+
1813+
warnings.warn(
1814+
"Passing a custom shell_cls is experimental and may break "
1815+
"in future releases.",
1816+
ExperimentalAPIWarning,
1817+
stacklevel=2,
1818+
)
1819+
assert issubclass(shell_cls, Gptcmd)
1820+
shell = shell_cls(config=config)
18101821
except ConfigError as e:
18111822
print(f"Couldn't read config: {e}")
18121823
return False
@@ -1843,6 +1854,13 @@ def main() -> bool:
18431854
return True
18441855

18451856

1857+
def main() -> bool:
1858+
"""
1859+
Setuptools requires a callable entry point to build an installable script
1860+
"""
1861+
return _run(Gptcmd)
1862+
1863+
18461864
if __name__ == "__main__":
18471865
success = main()
18481866
if success:

0 commit comments

Comments
 (0)