jdx / usage

A specification for CLIs
https://usage.jdx.dev
MIT License
157 stars 6 forks source link

`usage bash`: add support for reading script from a pipe #157

Open powerman opened 3 weeks ago

powerman commented 3 weeks ago

I've tried to quickly test usage with usage bash <(printf '#!/bin/bash\n#USAGE bin "pipe"\necho ok\n') and noticed it does not work (maybe because input file type is a pipe).

$ bash <(printf '#!/bin/bash\n#USAGE bin "pipe"\necho ok\n')
ok
$ usage bash <(printf '#!/bin/bash\n#USAGE bin "pipe"\necho ok\n')
$ echo $?
0
$ ls -l <(printf '#!/bin/bash\n#USAGE bin "pipe"\necho ok\n')
lr-x------ 1 powerman powerman 64 ноя  5 09:08 /proc/self/fd/12 -> 'pipe:[29095089]'
$ cat <(printf '#!/bin/bash\n#USAGE bin "pipe"\necho ok\n')
#!/bin/bash
#USAGE bin "pipe"
echo ok
$