cost 114 ms
無法為“貨物測試”提供 CLI 參數

[英]Unable to provide CLI arguments to `cargo test`

我曾經能夠從命令行界面運行特定的命名測試,如下所示: cargo test <test_name> 。 但是現在這給了我錯誤 cargo test的其他論據也不起作用。 導致錯誤的行是測試設置中的這一行: let cli_default_args = Arc::new(cli_a ...

如何使用 structopt 創建嵌套子命令?

[英]How to create nested subcommands with structopt?

介紹我目前有使用structopt的子命令,與其他答案類似。 但是,我希望嵌套子命令類似於docker的工作方式: 當前代碼 main.rsmod cli; use structopt::StructOpt; use crate::cli::{Opt, Command}; fn main() ...

在單獨的文件中定義時,structopt 無法找到其 Args 解析器

[英]structopt unable to find its Args parser when defined in a separate file

我開始使用 Rust 中的命令行工具,並從一開始就碰壁。 如果Opt結構是在main.rs定義的,我可以使用StructOpt解析命令行參數,但是由於我希望能夠將Opt結構傳遞到庫代碼中,我將它定義在它自己的文件中,以便其他部分圖書館的人都知道這是怎么回事。 這是轉儲錯誤最少的代碼版本,盡管我承認 ...

你能構建一個接受命令行 rest(或多個參數)的 structopt 解析器嗎?

[英]Can you build a structopt parser that takes the rest of the command line (or multiple arguments)?

structopt有一個巧妙的功能,它可以接受Vec<T>的類型化參數,這將吞噬命令行的 rest。#[structopt(long, short)] values: Vec<u32>, 它還具有接受您創建的類型的能力, 如果字段類型沒有FromStr實現,或者您想提供 ...

structopt: error[E0277]: trait bound `String: From<&OsStr>`

[英]structopt: error[E0277]: the trait bound `String: From<&OsStr>`

我正在使用 Rust 的structopt crate ,但是當我嘗試編譯示例時出現以下錯誤,error[E0277]: the trait bound `String: From&lt;&amp;OsStr&gt;` is not satisfied --&gt; bin/seq.rs:2 ...

Rustlang structopt 如何設置主目錄

[英]Rustlang structopt How to set the home directory

我正在為我的 cli 程序使用 crate structopt 。 如果 args 中的 output 目錄未通過,我想將主目錄設置為默認目錄。 以下是我的代碼,請建議我如何實施。 ...

StructOpt - 如何為 Vec 提供默認值?

[英]StructOpt - how to provide a default value for a Vec?

我正在尋找一種默認情況下用多個項目初始化structopt Vec字段的方法。 我可以為單個項目做到這一點: use structopt::StructOpt; #[derive(Debug, StructOpt)] pub struct Cli { #[structopt(default ...

是否可以在不解析命令行參數的情況下構建 StructOpt Args object 進行測試?

[英]Is it possible to construct a StructOpt Args object without parsing command line params for testing?

我有一個 fn main 正在通過 StructOpt 解析 arguments .. Args::from_args。 有沒有辦法創建這個 Args object 而無需實際啟動可執行文件進行測試? 我可以直接創建一個 Args object 嗎? 例如,我可以這樣做嗎 ...

如何使用structopt將特殊字符作為字符串參數傳遞?

[英]How to pass special characters as string argument using structopt?

我有一個命令行來搜索文件中的單詞。 我正在使用 StructOpt 來獲取用戶想要搜索的單詞。#[derive(Debug, StructOpt)] pub struct Command { pub word_to_search: Option&lt;String&gt;, } 當您編寫 ...

如何在 stuctopt 定義中訪問運行時定義的變量?

[英]How can I access a runtime-defined variable in stuctopt definitions?

我希望能夠使用變量的值(或者更好的是function(arg)的返回)作為使用 structopt 定義的 CLI 程序的 about 字符串。 最終目標是一個完全本地化的 CLI,它可以檢測系統語言或 ENV var,並加載本地化的字符串,這些字符串會被烘焙到--help消息等中。 默認情況下, ...

如何將版本信息從 Vergen 傳遞到 StructOpt?

[英]How can I pass version information from Vergen to StructOpt?

我正在嘗試在 Rust 中設置一個簡單的 CLI 程序,但我希望它根據git describe的信息而不是 Cargo.toml 文件中的信息顯示版本。 我設置了一些基本的依賴項: 一個 build.rs 文件使用 vergen 進行提升:extern crate vergen; use ver ...

StructOpt:如何將所有參數組合在一個字符串中?

[英]StructOpt: how to combine all arguments in a single string?

我想要做的是將用戶提供的命令行參數作為單個字符串訪問。 首先,我這樣做: 但是后來我決定嘗試用structopt來做它structopt卡住了。 使用structopt是否有可能達到預期的結果,我該怎么做? ...


排序:
質量:
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM