处理命令行参数和选项
在编写脚本时,比较有难度的方面之一是处理命令行参数。
One of the more challenging aspects of writing scripts is handling command line parameters.
在本文中,我讲述了一个用于处理命令行参数的库的设计过程,作为反射的一个实际的例子。
In this article, I've run through the design of a library for processing command line arguments as an example of reflection in action.
一旦处理了所有的命令行参数,就使用这些指定的选项以及输入、输出源和目标来开始输入的实际处理。
Once all the command line arguments are processed, the actual processing of the input starts, using the options and input and output sources and targets specified.
您可以使用单个的调用来负责命令行参数的实际处理,但是这个应用程序首先需要以某种方式将它的特定的形参定义到库中。
You can handle the actual processing of command line arguments with a single call, but the application first needs a way to define its particular parameters to the library.
在本月这一期的文章中,我将通过查看一个应用程序来更深入地讨论这一问题,这个应用程序是用于命令行参数处理的一个库,它能够很好地体现反射的强项和弱点。
This month I'm going even further by looking at an application that seems to be a good match for reflection's strengths and weaknesses: a library for command line argument processing.
它还有许多命令行实用程序、参数处理等示例。
It also has many examples of command-line utilities, argument processing, and so on.
比使用命令行参数时遇到的难题更棘手的通常涉及专门和专有语言扩展;处理它们需要人类程序员具备熟练的转换技能。
Challenges bigger than those met by command-line arguments often involve specialized and proprietary language extensions; these require skilled translation by human programmers.
selpg首先处理所有的命令行参数。
使用标准getopt函数处理大多数命令行参数都很简单(请参见侧栏了解更多详细信息)。
Handling most of the command-line arguments is simple using the standard getopt function (see the sidebar for more detail).
当以批处理方式工作时,我们从命令行设置所有参数。
When working in a batch, we set all the parameters from the command line.
或许您正在执行一份需要大量的命令行来处理参数的工作或者您想要设置一些别名。
Perhaps you are performing a job requiring a lot of command-line processing with arguments and would like to set a few aliases.
有一些库可以用来帮助进行命令行参数处理。
There are several libraries available to help with command line argument processing.
如果您还没有这样做,不要忘记删除所有跟踪文件并通过移除批处理文件中的命令行参数来关闭跟踪。
If you haven't already done so, don't forget to delete any trace files and turn off tracing by removing the command line parameter in the batch file.
这项任务可以通过只查找实际的命令行参数所需的字段信息来处理,但是我反而选择将查找和使用分开。
This task could be handled by just looking up the field information as needed for the actual command line arguments, but I've instead made a choice to separate the lookup from the usage.
foreach行上缺少的列表并不是输入错误:如果您省略某个列表,则foreach结构将处理命令行上给出的参数列表。
The missing list on the foreach line isn't a typo: If you omit a list, the foreach structure processes the list of arguments given on the command line.
在此基础上,分析了GCC的前端树表示、基于调用图的优化模式、GCC的命令行参数处理机制,并提出了一个跨文件编译模式模型。
We analyzed the abstract syntax tree represent of GCC, the optimization on the call-graph, and the approach to the command-line arguments.
和地理处理系统工具对话框的使用一样,你可以使用命令行工具键入工具命令符及参数并运行。
As you work with geoprocessing tools more and more, you may find the Command Line window a real work-saver. Instead of opening a tool dialog, you enter text for a tool and its parameters.
和地理处理系统工具对话框的使用一样,你可以使用命令行工具键入工具命令符及参数并运行。
As you work with geoprocessing tools more and more, you may find the Command Line window a real work-saver. Instead of opening a tool dialog, you enter text for a tool and its parameters.
应用推荐