diff options
| author | ruki <[email protected]> | 2026-03-26 23:59:26 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-03-26 23:59:26 +0800 |
| commit | c08081788e880f32f1835eab49aae5806cb19721 (patch) | |
| tree | 6444775397b86b47b75c337cd74f3a419ed2bdc1 /xmake/core/base/cli.lua | |
| parent | 6dd2023c43ab4fc46d9bce7599e6875e4ff33957 (diff) | |
improve more comments
Diffstat (limited to 'xmake/core/base/cli.lua')
| -rw-r--r-- | xmake/core/base/cli.lua | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/xmake/core/base/cli.lua b/xmake/core/base/cli.lua index fb1274537..7c2840b96 100644 --- a/xmake/core/base/cli.lua +++ b/xmake/core/base/cli.lua @@ -61,14 +61,24 @@ function cli._make_option(key, value, short, argv, argi) return cli._make_segment("option", short and ("-" .. key .. " " .. value) or ("--" .. key .. "=" .. value), argv, argi, { key = key, value = value, short = short or false }) end --- parse a argv string, command & sub-command should be omitted before calling this function +-- parse a command line string into structured segments +-- +-- @param args the command line string +-- @param flags the short flags set (optional), e.g. {v = true, f = true} +-- @return the parsed segments array [{type, key, value, short}, ...] -- @see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html +-- function cli.parse(args, flags) return cli.parsev(os.argv(args), flags) end --- parse a argv array, command & sub-command should be omitted before calling this function +-- parse an argv array into structured segments +-- +-- @param argv the arguments array +-- @param flags the short flags set (optional), e.g. {v = true, f = true} +-- @return the parsed segments array [{type, key, value, short}, ...] -- @see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html +-- function cli.parsev(argv, flags) local parsed = {} |
