在CLI11中处理特殊角色

发布于 2025-02-05 23:44:26 字数 393 浏览 1 评论 0原文

我有如下的代码,

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世态炎凉 2025-02-12 23:44:26

您的操作系统将命令输入并执行给定程序,将参数传递给其。

插值和打字命令中$字符的处理由您的操作系统处理,作为执行打字命令的一部分。您所编译的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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文