1.2.0 • Published 2 months ago

@magicdawn/x-args v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

x-args

play with cli commands like a composer

Build Status Coverage Status npm version npm downloads npm license

Install

$ pnpm add @magicdawn/x-args -g

# or
$ pnpm dlx @magicdawn/x-args
$ pnpx @magicdawn/x-args
$ bunx @magicdawn/x-args

Commands

default command

x-args -f './*.*' -c $'cwebp :file -o \':dir/:name_compressed.:ext\''

use -t to show available tokens

txt command

# use :line
x-args txt ./to-be-processed.txt -c $'echo \':line\''

features that native xargs does not have

  • comment, x-args txt support // or # comment, I suggest use .conf extenstion, so that editors can recognize # comment
  • live reload, x-args txt read txt file, exec command, and read txt again, so edit after command start will works as well
  • wait input update: use -w,--wait, so that this command will not exit but to wait txt file update. use --wait-timeout 1h to delay 1h 1 hour.

Templates

  • use :line for whole line
  • use :args0 / :arg0 for single arg
  • use -s / --split / --args-split to specify how to turn :line to :args0, default using a space

when input is a filepath, and may contains space, use a different separator that has low possibility occurs in a filepath for example

  • ancient chinese character for Simplified chinese user: __纛恚掾旒__, --args-split '__纛恚掾旒__', 出处
  • english user, maybe a emoji combination ?

Tips

-c,--command

# x-args glob file command
x-args txt ./to-be-processed.txt -c $'echo :line'

# if :line contains space, must be quoted
x-args txt ./to-be-processed.txt -c $'echo \':line\''

a special shell syntax learn from zx, see

Changelog

CHANGELOG.md

License

the MIT License http://magicdawn.mit-license.org