diff options
| author | ruki <[email protected]> | 2026-01-15 22:39:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-15 22:39:52 +0800 |
| commit | b9423c81cc0256e435e6337aa4d55b0ad5ec3784 (patch) | |
| tree | b0cb89cc6259b5eccd07ae3a40e2f91d881def60 /xmake/modules/cli/iconv.lua | |
| parent | ca0a72def014007446b720a823fc05f8e298af35 (diff) | |
improve cli.iconv
Diffstat (limited to 'xmake/modules/cli/iconv.lua')
| -rw-r--r-- | xmake/modules/cli/iconv.lua | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/xmake/modules/cli/iconv.lua b/xmake/modules/cli/iconv.lua index efb26c864..cc79bd934 100644 --- a/xmake/modules/cli/iconv.lua +++ b/xmake/modules/cli/iconv.lua @@ -22,14 +22,15 @@ import("core.base.option") -- supported encodings -local encodings = {"ansi", "ascii", "gb2312", "gbk", "iso8859", "ucs2", "ucs4", "utf16", "utf16be", "utf16le", "utf32", "utf32be", "utf32le", "utf8"} +local encodings = {"ansi", "ascii", "gb2312", "gbk", "iso8859", "ucs2", "ucs4", "utf16", "utf16be", "utf16bom", "utf16le", "utf16lebom", "utf32", "utf32be", "utf32le", "utf8", "utf8bom"} -- the options local options = { - {'f', "from", "kv", "utf8", "The source encoding.", values = encodings}, - {'t', "to", "kv", "utf8", "The target encoding.", values = encodings}, - {'o', "output", "kv", nil, "The output file."}, - {nil, "file", "v", nil, "The input file."} + {'f', "from", "kv", "utf8", "The source encoding.", values = encodings}, + {'t', "to", "kv", "utf8", "The target encoding.", values = encodings}, + {'l', "list", "k", nil, "List supported encodings."}, + {'o', "outputfile", "kv", nil, "The output file."}, + {nil, "inputfile", "v", nil, "The input file."} } -- main entry @@ -39,11 +40,17 @@ function main(...) local argv = table.pack(...) local args = option.parse(argv, options, "Convert encoding of a file.", "", - "Usage: xmake l cli.iconv [options] [file]") + "Usage: xmake l cli.iconv [options] [inputfile]") + + -- list encodings + if args.list then + print(table.concat(encodings, " ")) + return + end -- get arguments - local input_file = assert(args.file, "input file required!") - local output_file = assert(args.output, "output file required!") + local input_file = assert(args.inputfile, "input file required!") + local output_file = assert(args.outputfile, "output file required!") local from_code = args.from local to_code = args.to |
