From 6a877403f0bbff9bdb2d6d6c751b02ad74cbc450 Mon Sep 17 00:00:00 2001 From: AmirHosein Rostami <32750909+AHReccese@users.noreply.github.com> Date: Mon, 27 Jan 2025 06:01:28 -0500 Subject: [PATCH] Add/info (#54) * add `CLI_MORE_INFO` to `params.py` * add `--info` flag to CLI + implementation * add `--info` to `README.md` * `CHANGELOG.md` updated * add `--info` testcase in `test.yml` --- .github/workflows/test.yml | 4 ++++ CHANGELOG.md | 2 ++ README.md | 14 +++++++++----- dmeta/__main__.py | 15 ++++++++++++++- dmeta/params.py | 1 + 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d8cfae..32df233 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,6 +36,10 @@ jobs: run: | python -m pip install --upgrade pip pip install . + - name: CLI Tests - Info + run: | + python -m dmeta --info + dmeta --info - name: CLI Tests - Version Check run: | python -m dmeta --version diff --git a/CHANGELOG.md b/CHANGELOG.md index dc83c98..8fa988b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- `--info` flag in CLI ## [0.3] - 2025-01-13 ### Removed - `extract_namespaces` function in `util.py` diff --git a/README.md b/README.md index 17e303e..ba4674f 100644 --- a/README.md +++ b/README.md @@ -103,11 +103,6 @@ update_all(CONFIG_FILE_PATH) ⚠️ Use `--inplace` to apply the changes directly to the original file. -#### Version -```console -dmeta -v -dmeta --version -``` #### Clear metadata for a .docx file in place ```console dmeta --clear "./test_a.docx" --inplace @@ -124,6 +119,15 @@ dmeta --update "./test_a.xlsx" --config "./config.json" --inplace ```console dmeta --update-all --config "./config.json" ``` +#### Version +```console +dmeta -v +dmeta --version +``` +#### Info +```console +dmeta --info +``` ## Supported files | File format | support | diff --git a/dmeta/__main__.py b/dmeta/__main__.py index 9fb935c..7fe2cef 100644 --- a/dmeta/__main__.py +++ b/dmeta/__main__.py @@ -1,7 +1,8 @@ """DMeta main.""" import argparse +from art import tprint from dmeta.functions import run_dmeta -from dmeta.params import DMETA_VERSION +from dmeta.params import DMETA_VERSION, CLI_MORE_INFO, OVERVIEW def main(): @@ -50,12 +51,24 @@ def main(): type=str, help="the `config` command specifices the way metadata in the .docx files get updated." ) + parser.add_argument( + '--info', + action="store_true", + default=False, + help="the `info` flag gives general information about DMeta library." + ) parser.add_argument('--version', help="version", action='store_true', default=False) parser.add_argument('-v', help="version", action='store_true', default=False) args = parser.parse_known_args()[0] if args.version or args.v: print(DMETA_VERSION) return + if args.info: + tprint("DMeta") + tprint("V:" + DMETA_VERSION) + print(OVERVIEW) + print(CLI_MORE_INFO) + return run_dmeta(args) diff --git a/dmeta/params.py b/dmeta/params.py index 2c78c9f..6fdc69f 100644 --- a/dmeta/params.py +++ b/dmeta/params.py @@ -41,3 +41,4 @@ INVALID_CONFIG_FILE_NAME_ERROR = "Config file name is not a string." CONFIG_FILE_DOES_NOT_EXIST_ERROR = "Given config file doesn't exist." UPDATE_COMMAND_WITH_NO_CONFIG_FILE_ERROR = "No config file provided. Set the .json config file with --config command." +CLI_MORE_INFO = "For more information, visit the DMeta README at https://github.com/openscilab/dmeta"