Skip to content

Commit

Permalink
New options --list-fields, and --list-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef-Friedrich committed Feb 5, 2024
1 parent e85530b commit a8a26af
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ CLI Usage
[-x <number-or-all>] [-r <remap-pairs>] [-F]
[--rename <path-template>]
[-t <directory> | --only-filename] [-A] [-a] [-n]
[-K <fields>] [-L]
[-K <fields>] [--list-fields] [--list-functions] [-L]
[-g <glob-pattern> | --mscz | --mscx]
[-s <style-name> <value>] [--clean] [-Y <file>] [--s3]
[--s4] [--reset-small-staffs] [--list-fonts]
Expand Down Expand Up @@ -563,6 +563,10 @@ CLI Usage
Skip the rename action if the fields specified in <fields>
are empty. Multiple fields can be separated by commas, e.
g.: composer,title
--list-fields List all available fields that can be used in the path
templates.
--list-functions List all available functions that can be used in the path
templates.

selection:
The following options affect how the manager selects the MuseScore files.
Expand Down
4 changes: 3 additions & 1 deletion autocomplete.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@



_shtab_musescore_manager_option_strings=('-h' '--help' '--print-completion' '-C' '--config-file' '-b' '--backup' '-d' '--dry-run' '--catch-errors' '-m' '--mscore' '--save-in-mscore' '-e' '--executable' '-E' '--export' '--compress' '-V' '--version' '-v' '--verbose' '-k' '--color' '--no-color' '--diff' '--print-xml' '-c' '--clean-meta' '-D' '--delete-duplicates' '-i' '--distribute-fields' '-j' '--json' '-l' '--log' '-y' '--synchronize' '-S' '--set-field' '--metatag' '--metatag-meta' '--vbox' '--vbox-meta' '--title' '--subtitle' '--composer' '--lyricist' '-x' '--extract' '--extract-lyrics' '-r' '--remap' '--remap-lyrics' '-F' '--fix' '--fix-lyrics' '--rename' '-t' '--target' '--only-filename' '-A' '--alphanum' '-a' '--ascii' '-n' '--no-whitespace' '-K' '--skip-if-empty' '-L' '--list-files' '-g' '--glob' '--mscz' '--mscx' '-s' '--style' '--clean' '-Y' '--style-file' '--s3' '--styles-v3' '--s4' '--styles-v4' '--reset-small-staffs' '--list-fonts' '--text-font' '--title-font' '--musical-symbol-font' '--musical-text-font' '--staff-space' '--page-size' '--a4' '--din-a4' '--letter' '--margin' '--show-header' '--no-show-header' '--header-first-page' '--no-header-first-page' '--different-odd-even-header' '--no-different-odd-even-header' '--header' '--header-odd-even' '--show-footer' '--no-show-footer' '--footer-first-page' '--no-footer-first-page' '--different-odd-even-footer' '--no-different-odd-even-footer' '--footer' '--footer-odd-even')
_shtab_musescore_manager_option_strings=('-h' '--help' '--print-completion' '-C' '--config-file' '-b' '--backup' '-d' '--dry-run' '--catch-errors' '-m' '--mscore' '--save-in-mscore' '-e' '--executable' '-E' '--export' '--compress' '-V' '--version' '-v' '--verbose' '-k' '--color' '--no-color' '--diff' '--print-xml' '-c' '--clean-meta' '-D' '--delete-duplicates' '-i' '--distribute-fields' '-j' '--json' '-l' '--log' '-y' '--synchronize' '-S' '--set-field' '--metatag' '--metatag-meta' '--vbox' '--vbox-meta' '--title' '--subtitle' '--composer' '--lyricist' '-x' '--extract' '--extract-lyrics' '-r' '--remap' '--remap-lyrics' '-F' '--fix' '--fix-lyrics' '--rename' '-t' '--target' '--only-filename' '-A' '--alphanum' '-a' '--ascii' '-n' '--no-whitespace' '-K' '--skip-if-empty' '--list-fields' '--list-functions' '-L' '--list-files' '-g' '--glob' '--mscz' '--mscx' '-s' '--style' '--clean' '-Y' '--style-file' '--s3' '--styles-v3' '--s4' '--styles-v4' '--reset-small-staffs' '--list-fonts' '--text-font' '--title-font' '--musical-symbol-font' '--musical-text-font' '--staff-space' '--page-size' '--a4' '--din-a4' '--letter' '--margin' '--show-header' '--no-show-header' '--header-first-page' '--no-header-first-page' '--different-odd-even-header' '--no-different-odd-even-header' '--header' '--header-odd-even' '--show-footer' '--no-show-footer' '--footer-first-page' '--no-footer-first-page' '--different-odd-even-footer' '--no-different-odd-even-footer' '--footer' '--footer-odd-even')

_shtab_musescore_manager_pos_0_COMPGEN=_shtab_compgen_files
_shtab_musescore_manager__C_COMPGEN=_shtab_compgen_files
Expand Down Expand Up @@ -65,6 +65,8 @@ _shtab_musescore_manager__a_nargs=0
_shtab_musescore_manager___ascii_nargs=0
_shtab_musescore_manager__n_nargs=0
_shtab_musescore_manager___no_whitespace_nargs=0
_shtab_musescore_manager___list_fields_nargs=0
_shtab_musescore_manager___list_functions_nargs=0
_shtab_musescore_manager__L_nargs=0
_shtab_musescore_manager___list_files_nargs=0
_shtab_musescore_manager___mscz_nargs=0
Expand Down
2 changes: 1 addition & 1 deletion autocomplete.tcsh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


complete musescore-manager \
'c/--/(a4 alphanum ascii backup catch-errors clean clean-meta color composer compress config-file delete-duplicates diff different-odd-even-footer different-odd-even-header din-a4 distribute-fields dry-run executable export extract extract-lyrics fix fix-lyrics footer footer-first-page footer-odd-even glob header header-first-page header-odd-even help json letter list-files list-fonts log lyricist margin metatag metatag-meta mscore mscx mscz musical-symbol-font musical-text-font no-color no-different-odd-even-footer no-different-odd-even-header no-footer-first-page no-header-first-page no-show-footer no-show-header no-whitespace only-filename page-size print-completion print-xml remap remap-lyrics rename reset-small-staffs s3 s4 save-in-mscore set-field show-footer show-header skip-if-empty staff-space style style-file styles-v3 styles-v4 subtitle synchronize target text-font title title-font vbox vbox-meta verbose version)/' \
'c/--/(a4 alphanum ascii backup catch-errors clean clean-meta color composer compress config-file delete-duplicates diff different-odd-even-footer different-odd-even-header din-a4 distribute-fields dry-run executable export extract extract-lyrics fix fix-lyrics footer footer-first-page footer-odd-even glob header header-first-page header-odd-even help json letter list-fields list-files list-fonts list-functions log lyricist margin metatag metatag-meta mscore mscx mscz musical-symbol-font musical-text-font no-color no-different-odd-even-footer no-different-odd-even-header no-footer-first-page no-header-first-page no-show-footer no-show-header no-whitespace only-filename page-size print-completion print-xml remap remap-lyrics rename reset-small-staffs s3 s4 save-in-mscore set-field show-footer show-header skip-if-empty staff-space style style-file styles-v3 styles-v4 subtitle synchronize target text-font title title-font vbox vbox-meta verbose version)/' \
'c/-/(- A C D E F K L S V Y a b c d e g h i j k l m n r s t v x y)/' \
'n/--print-completion/(bash zsh tcsh)/' \
'n/-C/f/' \
Expand Down
2 changes: 2 additions & 0 deletions autocomplete.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ _shtab_musescore_manager_options=(
{-a,--ascii}"[Use only ASCII characters.]"
{-n,--no-whitespace}"[Replace all whitespaces with dashes or sometimes underlines.]"
{-K,--skip-if-empty}"[Skip the rename action if the fields specified in \<fields\> are empty. Multiple fields can be separated by commas, e. g.\: composer,title]:rename_skip:"
"--list-fields[List all available fields that can be used in the path templates.]"
"--list-functions[List all available functions that can be used in the path templates.]"
{-L,--list-files}"[Only list files and do nothing else.]"
{-g,--glob}"[Handle only files which matches against Unix style glob patterns (e. g. \"\*.mscx\", \"\* - \*\"). If you omit this option, the standard glob pattern \"\*.msc\[xz\]\" is used.]:selection_glob:"
"--mscz[Take only \"\*.mscz\" files into account.]"
Expand Down
6 changes: 5 additions & 1 deletion docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Comande line interface
[-x <number-or-all>] [-r <remap-pairs>] [-F]
[--rename <path-template>]
[-t <directory> | --only-filename] [-A] [-a] [-n]
[-K <fields>] [-L]
[-K <fields>] [--list-fields] [--list-functions] [-L]
[-g <glob-pattern> | --mscz | --mscx]
[-s <style-name> <value>] [--clean] [-Y <file>] [--s3]
[--s4] [--reset-small-staffs] [--list-fonts]
Expand Down Expand Up @@ -171,6 +171,10 @@ Comande line interface
Skip the rename action if the fields specified in <fields>
are empty. Multiple fields can be separated by commas, e.
g.: composer,title
--list-fields List all available fields that can be used in the path
templates.
--list-functions List all available functions that can be used in the path
templates.

selection:
The following options affect how the manager selects the MuseScore files.
Expand Down
24 changes: 24 additions & 0 deletions mscxyz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
from typing import Sequence

import shtab
import tmep

import mscxyz.export
from mscxyz import utils
from mscxyz.fields import FieldsManager
from mscxyz.meta import Metatag, Vbox
from mscxyz.rename import rename
from mscxyz.score import Score
Expand Down Expand Up @@ -435,6 +437,20 @@ def setup_parser() -> argparse.ArgumentParser:
"Multiple fields can be separated by commas, e. g.: composer,title",
)

rename.add_argument(
"--list-fields",
dest="rename_list_fields",
action="store_true",
help="List all available fields that can be used in the path templates.",
)

rename.add_argument(
"--list-functions",
dest="rename_list_functions",
action="store_true",
help="List all available functions that can be used in the path templates.",
)

###############################################################################
# selection
###############################################################################
Expand Down Expand Up @@ -774,6 +790,14 @@ def list_styles(version: int) -> None:
list_styles(4)
return

if args.rename_list_fields:
FieldsManager.print()
return

if args.rename_list_functions:
print(tmep.get_doc())
return

selection_glob: str = args.selection_glob
if args.selection_mscz:
selection_glob = "*.mscz"
Expand Down
5 changes: 5 additions & 0 deletions mscxyz/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,8 @@ def export_json(self) -> Path:
json.dump(self.export_to_dict(), output, indent=4)
output.close()
return result_path

@staticmethod
def print() -> None:
for field in FieldsManager.fields:
print(f"{field.name}: {field.description}")
2 changes: 2 additions & 0 deletions mscxyz/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class DefaultArguments:
rename_ascii: bool = False
rename_no_whitespace = False
rename_skip: Optional[str] = None
rename_list_fields: bool = False
rename_list_functions: bool = False

# selection
selection_list: bool = False
Expand Down

0 comments on commit a8a26af

Please sign in to comment.