From 33983b2a54666555d8865481a6b94f89c638cfd4 Mon Sep 17 00:00:00 2001 From: Michael Hofrichter Date: Fri, 27 Feb 2026 14:43:21 -0600 Subject: [PATCH 1/2] add -list-servers argument --- .bumpversion.cfg | 2 +- .gitignore | 3 +++ CHANGELOG.md | 6 +++++ README.md | 6 +++-- docassemblecli/commands.py | 46 ++++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 6 files changed, 61 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 6524918..b624ea6 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.0.25 +current_version = 0.0.26 commit = True tag = True diff --git a/.gitignore b/.gitignore index b178552..d5b5122 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ newversion.sh .history .mypy_cache */.mypy_cache +Icon +.DS_Store +Icon? \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e0bf7e..212a044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 0.0.26 - 2026-02-27 + +### Added + +- `--list-servers` argument for the dainstall command. + ## 0.0.23 - 2025-06-12 ### Added diff --git a/README.md b/README.md index a97c83b..ad7ec50 100644 --- a/README.md +++ b/README.md @@ -147,8 +147,8 @@ You can run `dainstall --help` to get more information about how usage: dainstall [-h] [--apiurl APIURL] [--apikey APIKEY] [--norestart] [--watch] [--force-restart] [--server SERVER] [--playground] - [--project PROJECT] [--add] [--noconfig] [--debug] - [directory] + [--project PROJECT] [--add] [--noconfig] [--debug] + [--list-servers] [directory] positional arguments: directory @@ -171,6 +171,8 @@ You can run `dainstall --help` to get more information about how --add add another server to the .docassemblecli config file --noconfig do not use the .docassemblecli config file --debug use verbose logging + --list-servers Lists out the names and urls of all servers in the + .docassemblecli configuration file For example, you might want to pass the URL and API key in the command itself: diff --git a/docassemblecli/commands.py b/docassemblecli/commands.py index afad93d..a790351 100644 --- a/docassemblecli/commands.py +++ b/docassemblecli/commands.py @@ -318,6 +318,36 @@ def name_from_url(url): return name +def list_servers(): + dotfile = os.path.join(os.path.expanduser("~"), ".docassemblecli") + if os.path.isfile(dotfile): + try: + with open(dotfile, "r", encoding="utf-8") as fp: + env = yaml.load(fp, Loader=yaml.FullLoader) + except Exception as err: + sys.stderr.write( + "Unable to load .docassemblecli file. " + + err.__class__.__name__ + + ": " + + str(err) + + "\n" + ) + env = [] + else: + env = [] + if isinstance(env, dict) and "apikey" in env and "apiurl" in env: + env["name"] = name_from_url(str(env["apiurl"])) + env = [env] + if not isinstance(env, list): + sys.stderr.write("Format of .docassemblecli file is not a list; ignoring.\n") + env = [] + return [ + (item["name"], item["apiurl"]) + for item in env + if isinstance(item, dict) and "name" in item and "apiurl" in item + ] + + def wait_for_server(playground:bool, task_id, apikey, apiurl): if playground: sys.stdout.write("Waiting for server to restart.") @@ -395,11 +425,27 @@ def dainstall(): parser.add_argument("--add", help="add another server to the .docassemblecli config file", action="store_true") parser.add_argument("--noconfig", help="do not use the .docassemblecli config file", action="store_true") parser.add_argument("--debug", help="use verbose logging", action="store_true") + parser.add_argument( + "--list-servers", + help="list servers in the .docassemblecli config file", + action="store_true", + ) args = parser.parse_args() if args.norestart and args.force_restart: return("The --norestart option can cannot be used with --force-restart.") if args.project and not args.playground: return("The --project option can only be used with --playground.") + if args.list_servers: + servers = list_servers() + if len(servers) == 0: + sys.stdout.write("No servers found in .docassemblecli\n") + else: + sys.stdout.write("Servers in .docassemblecli:\n") + sys.stdout.write(" Server Name: Server URL\n") + sys.stdout.write(" ------------ ----------\n") + for name, url in servers: + sys.stdout.write(f" {name}: {url}\n") + return if not args.add: if args.directory is None: parser.print_help() diff --git a/pyproject.toml b/pyproject.toml index bb9868f..e55d44d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "docassemblecli" -version = "0.0.25" +version = "0.0.26" authors = [ { name = "Jonathan Pyle", email = "jhpyle@gmail.com" }, ] From 7635b287131764f31baee9131ce1b3daef72923f Mon Sep 17 00:00:00 2001 From: Michael Hofrichter Date: Fri, 27 Feb 2026 14:58:24 -0600 Subject: [PATCH 2/2] slight tweak to handling single records --- docassemblecli/commands.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docassemblecli/commands.py b/docassemblecli/commands.py index a790351..6dbf9d5 100644 --- a/docassemblecli/commands.py +++ b/docassemblecli/commands.py @@ -335,8 +335,9 @@ def list_servers(): env = [] else: env = [] - if isinstance(env, dict) and "apikey" in env and "apiurl" in env: - env["name"] = name_from_url(str(env["apiurl"])) + if isinstance(env, dict): + if "apiurl" in env and "name" not in env: + env["name"] = name_from_url(str(env["apiurl"])) env = [env] if not isinstance(env, list): sys.stderr.write("Format of .docassemblecli file is not a list; ignoring.\n")