解析标准 [英] Standard for parsing

查看:58
本文介绍了解析标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在编写一个使用命令行界面的应用程序。它将通过在命令行上传递参数来配置
。程序

将在windows和linux中运行。


我想知道大多数linux / windows工具用来解析参数。


示例:ls -a或ls --help


我需要支持<的短(-a)和长(--help)版本br />
命令。如果我不得不选择,我希望长版本为

它们更容易记住。


我看过Getopt但说实话,我没有留下深刻印象。只有做短选项才会显示

,甚至不包含在Visual Studio中。


感谢您的帮助。

Hello everyone,

I am writing an application that uses a command line interface. It will
be configurable by passing arguments on the command line. The program
is going to run in windows and linux.

I was wondering what most linux/windows tools use to parse arguments.

Example: ls -a or ls --help

I need to support both short ( -a ) and long ( --help ) versions of the
commands. If I had to choose though, I would prefer long versions as
they are easier to remember.

I have looked at Getopt but to be honest, im not impressed. It appears
to only do short options and isnt even included in Visual Studio.

Thanks for your help.

推荐答案

31******@gmail.com 写道:
31******@gmail.com wrote:

大家好,


我正在编写一个使用命令行界面的应用程序。它将通过在命令行上传递参数来配置
。程序

将在windows和linux中运行。


我想知道大多数linux / windows工具用来解析参数。


示例:ls -a或ls --help


我需要支持<的短(-a)和长(--help)版本br />
命令。如果我不得不选择,我希望长版本为

它们更容易记住。


我看过Getopt但说实话,我没有留下深刻印象。看来

只做短选项,甚至不包括在Visual Studio中。
Hello everyone,

I am writing an application that uses a command line interface. It will
be configurable by passing arguments on the command line. The program
is going to run in windows and linux.

I was wondering what most linux/windows tools use to parse arguments.

Example: ls -a or ls --help

I need to support both short ( -a ) and long ( --help ) versions of the
commands. If I had to choose though, I would prefer long versions as
they are easier to remember.

I have looked at Getopt but to be honest, im not impressed. It appears
to only do short options and isnt even included in Visual Studio.



关于特定操作系统的问题在这里不是主题。

对于Linux我会建议comp.unix.programmer或

comp.os.linux.development.apps然而这种事情可以使用标准C来完成
。我不知道Windows

如何通过命令行参数,但如果你的问题基本上是

如何解析argv []指向的字符串那么你肯定

只需要标准C.它并不难,取决于你的应用程序的命令行选项可能有多复杂,但要做好准备

检查许多特殊情况的一些繁琐的工作。


如果您更详细地描述您的问题,我们应该能够提供更多的帮助。


out_of_topic {

对于Linux来看看getopt_long()


对于什么是值得的,我更喜欢一个字母选项

,因为它们输入速度更快。

}


Spiros Bousbouras

Questions about specific operating systems are not topical here.
For Linux I would suggest comp.unix.programmer or
comp.os.linux.development.apps However this kind of thing can
probably be done using standard C. I don''t know how Windows
passes command line arguments but if your problem is basically
how to parse the strings pointed to by argv[] then you definitely
only need standard C. It''s not hard , depending on how complicated
your application''s command line options may be , but be prepared for
some tedious work examining many special cases.

If you describe your problem in more detail we should be able to offer
more help.

out_of_topic {
For Linux have a look at getopt_long()

And for what is worth I prefer one letter options
because they are faster to type.
}

Spiros Bousbouras




如何脱离主题?


我不是在问如何解析命令行参数。我知道怎么做

那个。我想知道C

语言的程序员是否使用标准。我不专业,但我想知道是否有广泛用于解析的东西。已经固化的东西已经固化以捕获错误的输入和错误。


问题不是平台特定的。问题是关于C代码

,它被广泛用于解析命令。


我不知道它与这个组有什么关系。这是C组和

我询问C代码。


How is this out of topic?

I am not asking how to parse command line arguments. I know how to do
that. I was wondering if there is a standard that programmers of the C
language use. I am no professional but I was wondering if there was
something that is widely used for parsing. Something that has already
been solidified to catch bad input and errors.

The question is not platform specific. The question is about C code
that is widely used to parse commands.

I dont see how its not related to this group. This is the C group and
im asking about C code.


31 ****** @ gmail.com 写道:

大家好,


我正在编写一个使用命令行界面的应用程序。它将通过在命令行上传递参数来配置
。程序

将在windows和linux中运行。


我想知道大多数linux / windows工具用来解析参数。


示例:ls -a或ls --help


我需要支持<的短(-a)和长(--help)版本br />
命令。如果我不得不选择,我希望长版本为

它们更容易记住。

ant。

我看过Getopt但说实话,我没有留下深刻的印象。看来

只做短选项,甚至不包括在Visual Studio中。
Hello everyone,

I am writing an application that uses a command line interface. It will
be configurable by passing arguments on the command line. The program
is going to run in windows and linux.

I was wondering what most linux/windows tools use to parse arguments.

Example: ls -a or ls --help

I need to support both short ( -a ) and long ( --help ) versions of the
commands. If I had to choose though, I would prefer long versions as
they are easier to remember.
ant.
I have looked at Getopt but to be honest, im not impressed. It appears
to only do short options and isnt even included in Visual Studio.



这不是一个想要的消息来源组,但无论如何我都会帮忙。 glibc有一个

getopt_long函数,可能会按照你想要的那样做。

GNU,显然是开源的。由于可以在标准C中编写这样的

函数,您可以简单地将其重新编译为

您想要的任何其他系统(取决于许可条款) ,显然)。

如果你没有找到BSD实现或任何其他的b $ b实现,那么就有很多。

-

Flash Gordon

从我没有设置任何sig的另一台计算机上发布。

This isn''t a sources wanted group but I''ll help anyway. glibc has a
getopt_long function which probably does what you what you want. Being
GNU, it is obviously open source. Since it is possible to write such a
function in standard C you may well be able to simply re-compile it for
any other system you want (subject to licensing terms, obviously).
Failing that you could look for the BSD implementation or any other
implementation, there are plenty about.
--
Flash Gordon
Posting from a different computer on which I have not set up any sigs.


这篇关于解析标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆