diff options
| author | ruki <[email protected]> | 2020-10-22 23:25:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-10-22 23:25:52 +0800 |
| commit | 872afc2ba8d1f8cf1c1849ec42ea020365ec7553 (patch) | |
| tree | 6ed9e7541ad61107b3a45bd50313757d9dcd282b | |
| parent | 0a20260f3af11be51723b46464de78fca512993b (diff) | |
show xrepo logo
| -rw-r--r-- | xmake/core/base/option.lua | 6 | ||||
| -rw-r--r-- | xmake/core/main.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/base/option.lua | 10 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/main.lua | 55 |
4 files changed, 60 insertions, 13 deletions
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua index 558284edd..ef6cac2e4 100644 --- a/xmake/core/base/option.lua +++ b/xmake/core/base/option.lua @@ -484,17 +484,17 @@ function option.show_update_tips() end -- show logo -function option.show_logo() +function option.show_logo(logo) -- define logo - local logo = [[ + logo = logo or [[ _ __ ___ __ __ __ _| | ______ \ \/ / | \/ |/ _ | |/ / __ \ > < | \__/ | /_| | < ___/ /_/\_\_|_| |_|\__ \|_|\_\____| - by ruki, tboox.org + by ruki, xmake.io ]] -- make rainbow for logo diff --git a/xmake/core/main.lua b/xmake/core/main.lua index 935b78cca..fd1da9dd9 100644 --- a/xmake/core/main.lua +++ b/xmake/core/main.lua @@ -47,7 +47,7 @@ local menu = title = "${bright}xmake v" .. _VERSION .. ", A cross-platform build utility based on Lua${clear}" -- copyright -, copyright = "Copyright (C) 2015-2020 Ruki Wang, ${underline}tboox.org${clear}, ${underline}xmake.io${clear}" +, copyright = "Copyright (C) 2015-present Ruki Wang, ${underline}tboox.org${clear}, ${underline}xmake.io${clear}" -- the tasks: xmake [task] , function () diff --git a/xmake/core/sandbox/modules/import/core/base/option.lua b/xmake/core/sandbox/modules/import/core/base/option.lua index d9dfefa97..2b527dd46 100644 --- a/xmake/core/sandbox/modules/import/core/base/option.lua +++ b/xmake/core/sandbox/modules/import/core/base/option.lua @@ -56,6 +56,16 @@ function sandbox_core_base_option.defaults() return option.defaults() or {} end +-- show logo +function sandbox_core_base_option.show_logo(logo) + option.show_logo(logo) +end + +-- show options +function sandbox_core_base_option.show_options(options) + option.show_options(options) +end + -- parse arguments with the given options function sandbox_core_base_option.raw_parse(argv, options, opt) diff --git a/xmake/modules/private/xrepo/main.lua b/xmake/modules/private/xrepo/main.lua index b873a4b9c..79bdd828b 100644 --- a/xmake/modules/private/xrepo/main.lua +++ b/xmake/modules/private/xrepo/main.lua @@ -21,20 +21,57 @@ -- imports import("core.base.option") --- the options -local options = +-- main menu options +local _main_options = { - {nil, "action", "v", nil, "The sub-command name." } -, {nil, "options", "vs", nil, "The sub-command options." } + {}, + {'h', "help", "k", nil, "Print this help message and exit." }, + {}, + {nil, "action", "v", nil, "The sub-command name." }, + {nil, "options", "vs", nil, "The sub-command options." } } +-- show help menu of main program +function _main_show_help() + + -- show title + cprint("${bright}xRepo %s, A cross-platform C/C++ package manager based on Xmake.", xmake.version()) + + -- show copyright + cprint("Copyright (C) 2015-present Ruki Wang, ${underline}tboox.org${clear}, ${underline}xmake.io${clear}") + print("") + + -- show logo + local logo = [[ + __ ___ ___ ______ ____ _____ + \ \/ / | _ \| ____| _ \| _ | + > < | |_) | _| | |_) | |_| | + /_/\_\_| \___|_____|_| |_____| + + by ruki, xmake.io + ]] + option.show_logo(logo) + + -- show usage + cprint("${bright}Usage: $${clear cyan}xrepo [action] [options]") + + -- show options + option.show_options(_main_options) +end + -- main entry function main(...) - -- parse arguments - local argv = {...} - local opt = option.parse(argv, options, "A cross-platform C/C++ package manager based on Xmake." - , "" - , "Usage: xrepo [action] [options]") + -- parse argument options + local mainopt, errors = option.raw_parse(table.pack(...), _main_options) + if not mainopt then + _main_show_help() + raise(errors) + end + -- help? + if mainopt.help then + _main_show_help() + return + end end |
