Skip to content

Commit

Permalink
Add/info (#54)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
AHReccese authored Jan 27, 2025
1 parent fef5f9f commit 6a87740
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 |
Expand Down
15 changes: 14 additions & 1 deletion dmeta/__main__.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down Expand Up @@ -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)


Expand Down
1 change: 1 addition & 0 deletions dmeta/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 6a87740

Please sign in to comment.