BCDA-APS / adl2pydm

Convert MEDM's .adl files to PyDM's .ui format
Other
0 stars 4 forks source link

add command-line interface #26

Closed prjemian closed 5 years ago

prjemian commented 5 years ago

match the API of ald2ui & adl2boy

prjemian commented 5 years ago

Some programs are just not helpful, we must dig deeper it seems:

(base) prjemian@poof ~/.../eclipse/adl2pydm $ which adl2ui
/usr/local/epics/opi/bin/linux-x86_64/adl2ui
(base) prjemian@poof ~/.../eclipse/adl2pydm $ adl2ui --help
adl2ui -- Argument 1 = [--help] is unknown! possible are: '-flat and '-deviceonmenu' and '-nolegends' and '-v'
(base) prjemian@poof ~/.../eclipse/adl2pydm $ adl2ui
adl2ui -- sorry: no input file
prjemian commented 5 years ago

Looking at how adl2ui is used by synApps to autoconvert /.adl files to /.ui files, the rule used:

ifdef ADL2UI
UIs := $(subst $(ADL_DIR),$(UI_DIR),$(ADLs:.adl=.ui))
$(UI_DIR)%.ui: $(ADL_DIR)%.adl
    $(ADL2UI) $<
    $(MV) -f $(notdir $@) $(dir $@)
endif

says that the conversion is one file at a time, and implies the output goes into the same directory.

For unit testing, we want to be able to divert output to a directory of our choice. So, that should be an option.

CLI

adl2pydm [-o directory] adl_file

Also, accept either short -o or long --output forms.

Also, support -v and --version options, as well as standard help options (-h, --help).

prjemian commented 5 years ago

change -o, --output to -d, --dir

prjemian commented 5 years ago

as in:

usage: adl2pydm [-h] [-d DIR] [-v] adlfile

convert MEDM .adl screen file(s) to PyDM .ui format (https://github.com/BCDA-
APS/adl2pydm) v0.0.1+9.g437c5d3.dirty

positional arguments:
  adlfile            MEDM '.adl' file to convert

optional arguments:
  -h, --help         show this help message and exit
  -d DIR, --dir DIR  output directory, default: same directory as input file
  -v, --version      show program's version number and exit