Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/info #54

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"