@@ -34,7 +34,7 @@ conan create .
|
||||
|
||||
|
||||
## 示例程序
|
||||
构建简单的命令行程序
|
||||
构建简单的命令行程序,更多示例请参考`example`目录
|
||||
```c
|
||||
#include "ArgParse.h"
|
||||
#include <stdbool.h>
|
||||
@@ -42,7 +42,7 @@ conan create .
|
||||
#include <string.h>
|
||||
|
||||
ArgParse *Init() {
|
||||
ArgParse *ap = argParseInit("简单的命令行工具示例");
|
||||
ArgParse *ap = argParseInit("简单的命令行工具示例",NOVALUE);
|
||||
|
||||
// 添加第一个命令
|
||||
Command *cmd = argParseAddCommand(
|
||||
|
||||
@@ -6,7 +6,7 @@ import os
|
||||
|
||||
class loggingRecipe(ConanFile):
|
||||
name = "cargparse"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
license = "MIT"
|
||||
author = "321640253@qq.com"
|
||||
url = "https://gitea.youmetme.wang/youmetme/logging"
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define NORETURN __declspec(noreturn)
|
||||
#else
|
||||
#define NORETURN _Noreturn
|
||||
#endif
|
||||
|
||||
#define ARG_DEFAULT_HELP_FLAG "--help"
|
||||
|
||||
typedef struct ArgParse ArgParse; // 解析器
|
||||
@@ -16,9 +22,9 @@ typedef int (*ArgParseCallback)(ArgParse *argParse,
|
||||
int val_len); // 回调函数
|
||||
|
||||
typedef enum {
|
||||
NOVALUE = 0, // 无值
|
||||
SINGLEVALUE, // 单值 例如: -i https://www.baidu.com
|
||||
MULTIVALUE, // 多值 例如: -s a b c 或 -s a -s b -s c等
|
||||
ArgParseNOVALUE = 0, // 无值
|
||||
ArgParseSINGLEVALUE, // 单值 例如: -i https://www.baidu.com
|
||||
ArgParseMULTIVALUE, // 多值 例如: -s a b c 或 -s a -s b -s c等
|
||||
} ArgParseValueType; // 值类型
|
||||
|
||||
typedef struct CommandArgs {
|
||||
@@ -303,7 +309,7 @@ char *argParseGenerateHelp(ArgParse *argParse);
|
||||
char *
|
||||
argParseGenerateArgErrorMsg(ArgParse *argParse, char *name, bool short_flag);
|
||||
|
||||
_Noreturn void argParseError(ArgParse *argParse,
|
||||
NORETURN void argParseError(ArgParse *argParse,
|
||||
Command *lastCommand,
|
||||
const char *prefix,
|
||||
const char *suffix);
|
||||
|
||||
@@ -818,7 +818,7 @@ bool argParseCheckCommandTriggered(ArgParse *argParse, char *command_name) {
|
||||
return command->is_trigged;
|
||||
}
|
||||
|
||||
_Noreturn void argParseError(ArgParse *argParse,
|
||||
NORETURN void argParseError(ArgParse *argParse,
|
||||
Command *lastCommand,
|
||||
const char *prefix,
|
||||
const char *suffix) {
|
||||
|
||||
Reference in New Issue
Block a user