gpt4 book ai didi

command-line - 命令行动词参数的约定 -a 与 --arg

转载 作者:行者123 更新时间:2023-12-01 13:38:37 25 4
gpt4 key购买 nike

我刚刚注意到动词样式命令参数的模式(在 git 和 .NET 的 CommandLineParser 库中),并想知道是否有人可以确认:
myprog dothis -a "someArg"

  • -a
  • --arg

  • 单破折号前缀和双破折号前缀有什么区别?单破折号前缀是否始终用于单字母参数说明符,其中双破折号前缀始终用于参数的“长名称”?

    是否有某个地方有正式的约定来插入这一点,还是普遍接受的非正式做法? (或者我只是在做些什么?)

    只是好奇......我从未注意到 git 中的模式,CommandLineParser 文档非常薄,一些博客文章或其他内容涉及约定。

    (就此而言......这种动词/参数的风格甚至叫什么?我似乎找不到太多关于它的东西)

    最佳答案

    来自维基百科:https://en.wikipedia.org/wiki/Command-line_interface

    类 Unix 系统中的选项约定

    In Unix-like systems, the ASCII hyphen-minus begins options; the new (and GNU) convention is to use two hyphens then a word (e.g. --create) to identify the option's use while the old convention (and still available as an option for frequently-used options) is to use one hyphen then one letter (e.g. -c); if one hyphen is followed by two or more letters it may mean two options are being specified, or it may mean the second and subsequent letters are a parameter (such as filename or date) for the first option.

    Two hyphen-minus characters without following letters (--) may indicate that the remaining arguments should not be treated as options, which is useful for example if a file name itself begins with a hyphen, or if further arguments are meant for an inner command (e.g. sudo). Double hyphen-minuses are also sometimes used to prefix "long options" where more descriptive option names are used. This is a common feature of GNU software. The getopt function and program, and the getopts command are usually used for parsing command-line options.

    关于command-line - 命令行动词参数的约定 -a 与 --arg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42183794/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com