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

[Request] Allow short option to not be first letter of long #247

Open
kescobo opened this issue Jun 14, 2023 · 5 comments
Open

[Request] Allow short option to not be first letter of long #247

kescobo opened this issue Jun 14, 2023 · 5 comments
Labels
design decision help wanted Extra attention is needed

Comments

@kescobo
Copy link

kescobo commented Jun 14, 2023

Is there a reason (other than preference) for this to error?

It seems pretty common to have single letter options that are different from the first letter of the long option,
either for style (eg -x == --extract) or because multiple options start with the same letter (I ran into this because I have --debug and --default options, this means that only one can have a one-letter version).

@kescobo kescobo added the bug Something isn't working label Jun 14, 2023
@kescobo
Copy link
Author

kescobo commented Jun 14, 2023

Sorry - this got labeled a bug automatically, I don't think it's that :-)

@Roger-luo
Copy link
Collaborator

Roger-luo commented Jun 15, 2023

Yes, this is intended for the macro interface, this is because the macro interface is essentially the overlapping semantic between Julia and the shell script, I think allowing this confuses quite a lot, e.g the options are all Julia keywords, the macro interface aims to make sure things are readable by just reading Julia code. Thus I'd recommend you to not use a different first letter, I don't think it's a good style...

But... if you really really want to do this, you can directly construct the CLI object, then call the emit function manually, that way you have the flexibility and not restricted by any Julia semantic.

https://github.com/comonicon/Comonicon.jl/blob/main/test/codegen/bash.jl#L42

@Roger-luo Roger-luo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2023
@Roger-luo Roger-luo reopened this Jun 15, 2023
@Roger-luo
Copy link
Collaborator

actually, maybe we can let this issue open for a while to see if there are new opinions, but this has been a quite long behavior in this package, so I cannot change anything until the next minor release.

@kescobo
Copy link
Author

kescobo commented Jun 16, 2023

Thus I'd recommend you to not use a different first letter, I don't think it's a good style...

I can understand this completely, but enforcing style with an error if there's not a technical limitation seems odd to me 🤷 (particularly when there's a long tradition of command line tools that violate this style). Appreciate the consideration!

@songtaogui
Copy link

Is there any updates on this request? I voted for @kescobo , since I used diff short and long first letters often. Besides, many popular CLIs in bioinformatic field use this style, and considering their extensive user base, we usually need to set parameters close to them for users to better adapt to our tools.

for example, a widely used tool samtools:

samtools view

Usage: samtools view [options] <in.bam>|<in.sam>|<in.cram> [region ...]

Output options:
  -b, --bam                  Output BAM
  -C, --cram                 Output CRAM (requires -T)
  -1, --fast                 Use fast BAM compression (and default to --bam)
  -u, --uncompressed         Uncompressed BAM output (and default to --bam)
  -h, --with-header          Include header in SAM output
  -H, --header-only          Print SAM header only (no alignments)
      --no-header            Print SAM alignment records only [default]
  -c, --count                Print only the count of matching records
  -o, --output FILE          Write output to FILE [standard output]
  -U, --unoutput FILE, --output-unselected FILE
                             Output reads not selected by filters to FILE
  -p, --unmap                Set flag to UNMAP on reads not selected
                             then write to output file.
  -P, --fetch-pairs          Retrieve complete pairs even when outside of region
Input options:
  -t, --fai-reference FILE   FILE listing reference names and lengths
  -M, --use-index            Use index and multi-region iterator for regions
      --region[s]-file FILE  Use index to include only reads overlapping FILE
  -X, --customized-index     Expect extra index file argument after <in.bam>

Filtering options (Only include in output reads that...):
  -L, --target[s]-file FILE  ...overlap (BED) regions in FILE
  -r, --read-group STR       ...are in read group STR
  -R, --read-group-file FILE ...are in a read group listed in FILE
  -N, --qname-file FILE      ...whose read name is listed in FILE
  -d, --tag STR1[:STR2]      ...have a tag STR1 (with associated value STR2)
  -D, --tag-file STR:FILE    ...have a tag STR whose value is listed in FILE
  -q, --min-MQ INT           ...have mapping quality >= INT
  -l, --library STR          ...are in library STR
  -m, --min-qlen INT         ...cover >= INT query bases (as measured via CIGAR)
  -e, --expr STR             ...match the filter expression STR
  -f, --require-flags FLAG   ...have all of the FLAGs present
  -F, --excl[ude]-flags FLAG ...have none of the FLAGs present
      --rf, --incl-flags, --include-flags FLAG
                             ...have some of the FLAGs present
  -G FLAG                    EXCLUDE reads with all of the FLAGs present
      --subsample FLOAT      Keep only FLOAT fraction of templates/read pairs
      --subsample-seed INT   Influence WHICH reads are kept in subsampling [0]
  -s INT.FRAC                Same as --subsample 0.FRAC --subsample-seed INT

Processing options:
      --add-flags FLAG       Add FLAGs to reads
      --remove-flags FLAG    Remove FLAGs from reads
  -x, --remove-tag STR
               Comma-separated read tags to strip (repeatable) [null]
      --keep-tag STR
               Comma-separated read tags to preserve (repeatable) [null].
               Equivalent to "-x ^STR"
  -B, --remove-B             Collapse the backward CIGAR operation
  -z, --sanitize FLAGS       Perform sanitity checking and fixing on records.
                             FLAGS is comma separated (see manual). [off]

General options:
  -?, --help   Print long help, including note about region specification
  -S           Ignored (input format is auto-detected)
      --no-PG  Do not add a PG line
      --input-fmt-option OPT[=VAL]
               Specify a single input file format option in the form
               of OPTION or OPTION=VALUE
  -O, --output-fmt FORMAT[,OPT[=VAL]]...
               Specify output format (SAM, BAM, CRAM)
      --output-fmt-option OPT[=VAL]
               Specify a single output file format option in the form
               of OPTION or OPTION=VALUE
  -T, --reference FILE
               Reference sequence FASTA FILE [null]
  -@, --threads INT
               Number of additional threads to use [0]
      --write-index
               Automatically index the output files [off]
      --verbosity INT
               Set level of verbosity

@Roger-luo Roger-luo added help wanted Extra attention is needed design decision and removed bug Something isn't working labels Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design decision help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants