在CLI11中处理特殊角色
我有如下的代码,
flags->add_option("--name", name_, "The name.")->required();
我希望能够将字符串(例如aa $ p $ aa''()传递给
- 名称
参数。但是,这似乎与CLI11不起作用,并且名称被截断为“ AA”。我需要逃脱$
字符才能正确阅读字符串。因此,aa \ $ p \ $ aa
工作正常,我得到了预期的字符串(“ aa $ p $ aa”)。
将功能更改为add_flag()
也不起作用。
与上面的任何一个函数调用一样,有没有办法将任意字符串传递给参数?
I have code like the following
flags->add_option("--name", name_, "The name.")->required();
I want to be able to pass strings like "aa$p$aa" to the --name
parameter. However, this does not seem to work with CLI11, and the name gets truncated to just "aa". I need to escape the $
characters to properly read the strings. So aa\$p\$aa
works fine, and I get the expected string ("aa$p$aa").
Changing the function to add_flag()
does not work either.
Is there a way to be able to pass arbitrary strings to a parameter as with either function calls above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的操作系统将命令输入并执行给定程序,将参数传递给其。
插值和打字命令中
$
字符的处理由您的操作系统处理,作为执行打字命令的一部分。您所编译的C ++程序作为参数接收转换的参数。您的C ++程序无法控制甚至执行它之前发生的事情。Your operating system takes the command you type in and executes the given program, passing the parameters to it.
The interpolation, and the handling of
$
characters in typed-in commands is handled by your operating system as part of executing the typed-in command. Your compiled C++ program receives the transformed arguments, as parameters. Your C++ program has no means to control what has happened before it was even executed.