c-blake / cligen

Nim library to infer/generate command-line-interfaces / option / argument parsing; Docs at
https://c-blake.github.io/cligen/
ISC License
509 stars 24 forks source link

Permissive spelling does not work for boolean sub-command #114

Closed pb-cdunn closed 5 years ago

pb-cdunn commented 5 years ago
+ falconc m4filt-ipaRunner --ovls-fofn merged.fofn --n-proc 16 --max-diff 80 --max-cov 100 --min-cov 1 --bestn 20 --min-len 4000 --gap-filt --output-fn ./ercreads.ovl --filter-log m4-readfilt.log

Bool option "gap-filt" non-boolean argument ("--output-fn")
m4filt-ipaRunner [required&optional-params]
Runs the multi-stage m4 overlap filter for IPA. In stage one, reads that trigger a filter are marked including containment,
gaps in coverage along the A-read, and repeat reads. In stage two the filters are applied and the N-best overlaps are kept for
the 5prime and 3prime of each read.
Options(opt-arg sep :|=|spc):
  -h, --help                           print this cligen-erated help
  --help-syntax                        advanced: prepend,plurals,..
  -o=, --ovlsFofn=   string  REQUIRED  List of m4 files from ipa/raptor
  -i=, --idtStage1=  float   90.0      Stage one percent identity filter, formatted as percentage, overlaps < %idt are skipped
  --idtStage2=       float   90.0      Stage two percent identify filter
  -m=, --minLen=     int     6000      Minimum read length, reads shorter than minLen will be discarded
  --minCov=          int     2         Minimum number of overlaps on either side of a read
  --maxCov=          int     200       Maximum number of overlaps on either side of a read
  --maxDiff=         int     100       Reads are skipped is abs(5p-3p) overlap counts > maxDiff
  -b=, --bestN=      int     10        Keep N best overlaps at 5prime AND 3prime of a read
  --minDepth=        int     2         Depths lower than minDepth are considered gaps
  -g, --gapFilt      bool    false     Run depth filter, takes a little more time
  -n=, --nProc=      int     24        Number of processes to run locally
  -f=, --filterLog=  string  REQUIRED  Write read filter stats to this file
  --outputFn=        string  REQUIRED  Final m4 overlap file

I've switched most args to --posix-style, but I am forced still to use --gapFilt because of the above.

pb-cdunn commented 5 years ago
when isMainModule:
    import cligen
    dispatchMulti(
    ...
        [overlapFilter.falconRunner, cmdName = "m4filt-falconRunner",
         help = {
          "lasJson": "List of las files from falcon, e.g ../1-preads_ovl/las-merge-combine/las_fofn.json",
          "idtStage1": "Stage one percent identity filter, formatted as percentage, overlaps < %idt are skipped",
          "idtStage2": "Stage two percent identify filter",
          "minLen": "Minimum read length, reads shorter than minLen will be discarded",
          "minCov": "Minimum number of overlaps on either side of a read",
          "maxCov": "Maximum number of overlaps on either side of a read",
          "maxDiff": "Reads are skipped is abs(5p-3p) overlap counts > maxDiff",
          "bestN": "Keep N best overlaps at 5prime AND 3prime of a read",
          "minDepth": "Depths lower than minDepth are considered gaps",
          "gapFilt": "Run depth filter, takes a little more time",
          "nProc": "Number of processes to run locally",
          "filterLog": "Write read filter stats to this file",
          "outputFn": "Final m4 overlap file",
            }
        ],
c-blake commented 5 years ago

So, you mean long options associated with boolean-valued parameters not sub-commands, of course. I will have to look into this. For my own commands with bool parameters I have no trouble issuing flexible spelling.

pb-cdunn commented 5 years ago

Well, I haven't tried this except as a sub-command.

c-blake commented 5 years ago

Oh, ho! It works if the long option for a bool is the last thing on the command-line, but fails if it's earlier. The plot thickens. ;-)

c-blake commented 5 years ago

(I didn't mean to sound flip...This is definitely a bona fide bug I should fix. Will have to debug it, though.)

pb-cdunn commented 5 years ago

It's fine. I love it!

c-blake commented 5 years ago

It also only happens if the parameter != optionNormalize(parameter). So, if you need an instant fix you can probably use gapfilt in your Nim code, though in the long-term I do feel a burning need to fix this. (Anything with mixed case doesn't even make it into OptParser.noLongVal .)

c-blake commented 5 years ago

Ooops - I mean longNoVal.

pb-cdunn commented 5 years ago

Oh, I probably don't need a fix at all. Just thought you would be interested.

I plan to switch all these to gap_filt etc. in the code, and then I'll bet --gap-filt will work fine.

c-blake commented 5 years ago

Well, I am interested and I'm going to fix it..once I figure it out. (Not sure if gap_filt will work either since normalizing is also needed there.)

c-blake commented 5 years ago

github auto-closed this. I think it's fixed. Let me know if otherwise.

pb-cdunn commented 5 years ago

Thanks. We'll have to update our subtree, so just assume it's fixed unless we find a problem.

c-blake commented 5 years ago

Ok.