chendelin1982 3 年之前
父節點
當前提交
0866969ddc
共有 4 個文件被更改,包括 38 次插入0 次删除
  1. 3 0
      cli/README.md
  2. 10 0
      cli/install.sh
  3. 1 0
      cli/requirements.txt
  4. 24 0
      cli/stackhub.py

+ 3 - 0
cli/README.md

@@ -0,0 +1,3 @@
+## CLI
+
+This CLI solution is based on [tpyer](https://typer.tiangolo.com/)

+ 10 - 0
cli/install.sh

@@ -0,0 +1,10 @@
+pip3 install typer
+
+# install Github CLI and upgrade it
+sudo apt install dirmngr
+curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg
+echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
+sudo apt update
+sudo apt install gh
+sudo apt update
+sudo apt install gh

+ 1 - 0
cli/requirements.txt

@@ -0,0 +1 @@
+typer

+ 24 - 0
cli/stackhub.py

@@ -0,0 +1,24 @@
+#!/usr/bin/python3
+import os, io, sys, platform, shutil, urllib3, json, time, subprocess
+
+
+import typer
+
+app = typer.Typer()
+
+
+@app.command()
+def module(name: str):
+    typer.echo(f"Hello {name}")
+
+
+@app.command()
+def application(name: str, formal: bool = False):
+    if formal:
+        typer.echo(f"Goodbye Ms. {name}. Have a good day.")
+    else:
+        typer.echo(f"Bye {name}!")
+
+
+if __name__ == "__main__":
+    app()