Repository: google/argh (language: rust)

Issue:
Suggestion: `#[argh(rename = "name")]`
Problem: Often, fields that are option members have long (descriptive) names that make sense in the source code, but are too long to type for cli options. 
The attribute `short = 'x'` can only take single chars, so that can't be used to shorten them.

Solution: Adding a way to rename cli option members using `#[argh(rename = "name")]`.
Similar to `#[serde(rename = "name")]`.



Discussion / hints:
I like this suggestion a lot! next time I hack on argh I'll do this :)
Can't this already be done with overriding `long`?

```
struct Cmd {
     #[argh(option, long = "foo")]
     i_am_very_very_very_long: u8,
}
```
@trevarj But that doesn't work to rename `positional` args. In `--help` they will still be printed with their rust field name.

Fix patch:
diff --git a/argh_derive/src/help.rs b/argh_derive/src/help.rs
index 82bfc47..9a2c5b9 100644
--- a/argh_derive/src/help.rs
+++ b/argh_derive/src/help.rs
@@ -11,6 +11,7 @@ use {
     argh_shared::INDENT,
     proc_macro2::{Span, TokenStream},
     quote::quote,
+    syn::LitStr,
 };
 
 const SECTION_SEPARATOR: &str = "\n\n";
@@ -126,7 +127,9 @@ fn positional_usage(out: &mut String, field: &StructField<'_>) {
         out.push('[');
     }
     out.push('<');
-    out.push_str(&field.name.to_string());
+    let name =
+        field.attrs.arg_name.as_ref().map(LitStr::value).unwrap_or_else(|| field.name.to_string());
+    out.push_str(&name);
     if field.optionality == Optionality::Repeating {
         out.push_str("...");
     }


Test patch:
diff --git a/tests/lib.rs b/argh/tests/lib.rs
similarity index 98%
rename from tests/lib.rs
rename to argh/tests/lib.rs
index 9369bad..963540e 100644
--- a/tests/lib.rs
+++ b/argh/tests/lib.rs
@@ -872,6 +872,27 @@ Notes:
 Error codes:
   2 The blade is too dull.
   3 Out of fuel.
+"###,
+        );
+    }
+
+    #[allow(dead_code)]
+    #[derive(argh::FromArgs)]
+    /// Destroy the contents of <file>.
+    struct WithArgName {
+        #[argh(positional, arg_name = "name")]
+        username: String,
+    }
+
+    #[test]
+    fn with_arg_name() {
+        assert_help_string::<WithArgName>(
+            r###"Usage: test_arg_0 <name>
+
+Destroy the contents of <file>.
+
+Options:
+  --help            display usage information
 "###,
         );
     }