Skip to content

Commit b746dca

Browse files
authored
feat: abandon support for author meta (#379)
1 parent d17907f commit b746dca

13 files changed

+3
-76
lines changed

docs/specification.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ Adds metadata.
174174
| syntax | scope | description |
175175
| :------------------------------- | ------ | :------------------------------------------------------------------- |
176176
| `@meta version <value>` | any | Set the version for the command. |
177-
| `@meta author <value>` | any | Set the author for the command. |
178177
| `@meta dotenv [<path>]` | root | Load a dotenv file from a custom path, if persent. |
179178
| `@meta default-subcommand` | subcmd | Set the current subcommand as the default. |
180179
| `@meta require-tools <tool>,...` | any | Require certain tools to be available on the system. |
@@ -186,7 +185,6 @@ Adds metadata.
186185

187186
```sh
188187
# @meta version 1.0.0
189-
# @meta author nobody <nobody@example.com>
190188
# @meta dotenv
191189
# @meta dotenv .env.local
192190
# @meta require-tools git,yq

examples/multiline.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# are treated as the long description. A line which is not a comment ends the block.
55

66
# @meta version 1.0.0
7-
# @meta author nobody <nobody@example.com>
87

98
# @option --foo[=default|full|auto] Sunshine gleams over hills afar, bringing warmth and hope to every soul, yet challenges await as we journey forth, striving for dreams and joy in abundance. Peaceful rivers whisper secrets gently heard.
109
# * default: enables recommended style components.

src/command/mod.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ use crate::param::{EnvValue, FlagOptionValue, PositionalValue};
1313
use crate::parser::{parse, parse_symbol, Event, EventData, EventScope, Position};
1414
use crate::runtime::Runtime;
1515
use crate::utils::{
16-
AFTER_HOOK, BEFORE_HOOK, MAIN_NAME, META_AUTHOR, META_COMBINE_SHORTS, META_DEFAULT_SUBCOMMAND,
17-
META_DOTENV, META_INHERIT_FLAG_OPTIONS, META_REQUIRE_TOOLS, META_SYMBOL, META_VERSION,
18-
ROOT_NAME,
16+
AFTER_HOOK, BEFORE_HOOK, MAIN_NAME, META_COMBINE_SHORTS, META_DEFAULT_SUBCOMMAND, META_DOTENV,
17+
META_INHERIT_FLAG_OPTIONS, META_REQUIRE_TOOLS, META_SYMBOL, META_VERSION, ROOT_NAME,
1918
};
2019
use crate::Result;
2120

@@ -41,7 +40,6 @@ pub(crate) struct Command {
4140
pub(crate) subcommand_fns: HashMap<String, Position>,
4241
pub(crate) default_subcommand: Option<(usize, Position)>,
4342
pub(crate) aliases: Option<(Vec<String>, Position)>,
44-
pub(crate) author: Option<String>,
4543
pub(crate) version: Option<String>,
4644
pub(crate) names_checker: NamesChecker,
4745
pub(crate) share: Arc<RefCell<ShareData>>,
@@ -145,7 +143,6 @@ impl Command {
145143
CommandValue {
146144
name: self.cmd_name(),
147145
describe: self.describe.clone(),
148-
author: self.author.clone(),
149146
version: self.version.clone(),
150147
aliases: self.list_alias_names().clone(),
151148
flag_options,
@@ -170,10 +167,6 @@ impl Command {
170167
let cmd = Self::get_cmd(&mut root_cmd, "@version", position)?;
171168
cmd.version = Some(value);
172169
}
173-
EventData::Author(value) => {
174-
let cmd = Self::get_cmd(&mut root_cmd, "@author", position)?;
175-
cmd.author = Some(value);
176-
}
177170
EventData::Meta(key, value) => {
178171
let cmd = Self::get_cmd(&mut root_cmd, "@meta", position)?;
179172
match key.as_str() {
@@ -191,13 +184,6 @@ impl Command {
191184
cmd.version = Some(value.clone());
192185
}
193186
}
194-
META_AUTHOR => {
195-
if value.is_empty() {
196-
bail!("@meta(line {}) invalid version value", position)
197-
} else {
198-
cmd.author = Some(value.clone());
199-
}
200-
}
201187
_ => {}
202188
}
203189
cmd.metadata.push((key, value, position));
@@ -701,9 +687,6 @@ impl Command {
701687
if self.version.is_some() {
702688
output.push(self.render_version());
703689
}
704-
if let Some(author) = &self.author {
705-
output.push(author.to_string());
706-
}
707690
if !&self.describe.is_empty() {
708691
output.push(render_block("", &self.describe, wrap_width));
709692
}
@@ -872,7 +855,6 @@ impl Command {
872855
pub struct CommandValue {
873856
pub name: String,
874857
pub describe: String,
875-
pub author: Option<String>,
876858
pub version: Option<String>,
877859
pub aliases: Vec<String>,
878860
pub flag_options: Vec<FlagOptionValue>,

src/mangen.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ fn render_manpage(cmd: &Command, section: &str) -> String {
3030
render_subcommands_section(&mut roff, cmd, section);
3131
render_envs_section(&mut roff, cmd);
3232
render_version_section(&mut roff, cmd);
33-
render_author_section(&mut roff, cmd);
3433
roff.to_roff()
3534
}
3635

@@ -196,13 +195,6 @@ fn render_version_section(roff: &mut Roff, cmd: &Command) {
196195
}
197196
}
198197

199-
fn render_author_section(roff: &mut Roff, cmd: &Command) {
200-
if let Some(author) = &cmd.author {
201-
roff.control("SH", ["AUTHORS"]);
202-
roff.text([roman(author)]);
203-
}
204-
}
205-
206198
fn render_describe(body: &mut Vec<Inline>, describe: &str) {
207199
for line in describe.split('\n') {
208200
body.push(Inline::LineBreak);

src/parser.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ pub(crate) enum EventData {
3131
Describe(String),
3232
/// Version info
3333
Version(String),
34-
/// Author info
35-
Author(String),
3634
/// Metadata
3735
Meta(String, String),
3836
/// Define a subcommand, e.g. `@cmd A sub command`
@@ -158,15 +156,14 @@ fn parse_tag(input: &str) -> nom::IResult<&str, Option<EventData>> {
158156
fn parse_tag_text(input: &str) -> nom::IResult<&str, Option<EventData>> {
159157
map(
160158
pair(
161-
alt((tag("describe"), tag("version"), tag("author"), tag("cmd"))),
159+
alt((tag("describe"), tag("version"), tag("cmd"))),
162160
parse_tail,
163161
),
164162
|(tag, text)| {
165163
let text = text.to_string();
166164
Some(match tag {
167165
"describe" => EventData::Describe(text),
168166
"version" => EventData::Version(text),
169-
"author" => EventData::Author(text),
170167
"cmd" => EventData::Cmd(text),
171168
_ => unreachable!(),
172169
})
@@ -1098,7 +1095,6 @@ mod tests {
10981095
fn test_parse_line() {
10991096
assert_token!("# @describe A demo cli", Describe, "A demo cli");
11001097
assert_token!("# @version 1.0.0", Version, "1.0.0");
1101-
assert_token!("# @author Somebody", Author, "Somebody");
11021098
assert_token!("# @meta key", Meta, "key", "");
11031099
assert_token!("# @meta key value", Meta, "key", "value");
11041100
assert_token!("# @cmd A subcommand", Cmd, "A subcommand");

src/utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pub const ROOT_NAME: &str = "prog";
77
pub const MAIN_NAME: &str = "main";
88

99
pub(crate) const META_VERSION: &str = "version";
10-
pub(crate) const META_AUTHOR: &str = "author";
1110
pub(crate) const META_DOTENV: &str = "dotenv";
1211
pub(crate) const META_DEFAULT_SUBCOMMAND: &str = "default-subcommand";
1312
pub(crate) const META_INHERIT_FLAG_OPTIONS: &str = "inherit-flag-options";

tests/snapshots/integration__cli__export.snap

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ expression: stdout
55
{
66
"name": "options",
77
"describe": "All kinds of @option and @flag",
8-
"author": null,
98
"version": null,
109
"aliases": [],
1110
"flag_options": [
@@ -62,7 +61,6 @@ expression: stdout
6261
{
6362
"name": "options",
6463
"describe": "All kind of options",
65-
"author": null,
6664
"version": null,
6765
"aliases": [],
6866
"flag_options": [
@@ -651,7 +649,6 @@ expression: stdout
651649
{
652650
"name": "flags",
653651
"describe": "All kind of flags",
654-
"author": null,
655652
"version": null,
656653
"aliases": [],
657654
"flag_options": [
@@ -802,7 +799,6 @@ expression: stdout
802799
{
803800
"name": "options-one-hyphen",
804801
"describe": "Flags or options with single hyphen",
805-
"author": null,
806802
"version": null,
807803
"aliases": [],
808804
"flag_options": [
@@ -1044,7 +1040,6 @@ expression: stdout
10441040
{
10451041
"name": "options-notation-modifier",
10461042
"describe": "Value notation modifier",
1047-
"author": null,
10481043
"version": null,
10491044
"aliases": [],
10501045
"flag_options": [
@@ -1155,7 +1150,6 @@ expression: stdout
11551150
{
11561151
"name": "options-plus",
11571152
"describe": "All kind of options",
1158-
"author": null,
11591153
"version": null,
11601154
"aliases": [],
11611155
"flag_options": [
@@ -1750,7 +1744,6 @@ expression: stdout
17501744
{
17511745
"name": "flags-plus",
17521746
"describe": "All kind of flags",
1753-
"author": null,
17541747
"version": null,
17551748
"aliases": [],
17561749
"flag_options": [
@@ -1901,7 +1894,6 @@ expression: stdout
19011894
{
19021895
"name": "options-mixed",
19031896
"describe": "Mixed `-` and `+` options",
1904-
"author": null,
19051897
"version": null,
19061898
"aliases": [],
19071899
"flag_options": [
@@ -2012,7 +2004,6 @@ expression: stdout
20122004
{
20132005
"name": "options-prefixed",
20142006
"describe": "Prefixed option",
2015-
"author": null,
20162007
"version": null,
20172008
"aliases": [],
20182009
"flag_options": [
@@ -2110,7 +2101,6 @@ expression: stdout
21102101
{
21112102
"name": "options-assigned",
21122103
"describe": "Prefixed option",
2113-
"author": null,
21142104
"version": null,
21152105
"aliases": [],
21162106
"flag_options": [
@@ -2177,7 +2167,6 @@ expression: stdout
21772167
{
21782168
"name": "test1",
21792169
"describe": "",
2180-
"author": null,
21812170
"version": null,
21822171
"aliases": [],
21832172
"flag_options": [
@@ -2629,7 +2618,6 @@ expression: stdout
26292618
{
26302619
"name": "test2",
26312620
"describe": "",
2632-
"author": null,
26332621
"version": null,
26342622
"aliases": [],
26352623
"flag_options": [
@@ -2833,7 +2821,6 @@ expression: stdout
28332821
{
28342822
"name": "test3",
28352823
"describe": "",
2836-
"author": null,
28372824
"version": null,
28382825
"aliases": [],
28392826
"flag_options": [

tests/snapshots/integration__multiline__nowrap.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ prog -h
88
# OUTPUT
99
command cat >&2 <<-'EOF'
1010
prog 1.0.0
11-
nobody <nobody@example.com>
1211
How to use multiline help text
1312

1413
Extra lines after the comment tag accepts description, which don't start with an `@`,
@@ -45,7 +44,6 @@ exit 0
4544

4645
# BUILD_OUTPUT
4746
prog 1.0.0
48-
nobody <nobody@example.com>
4947
How to use multiline help text
5048

5149
Extra lines after the comment tag accepts description, which don't start with an `@`,

tests/snapshots/integration__multiline__wrap.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ prog -h
88
# OUTPUT
99
command cat >&2 <<-'EOF'
1010
prog 1.0.0
11-
nobody <nobody@example.com>
1211
How to use multiline help text
1312

1413
Extra lines after the comment tag accepts description, which don't start with
@@ -55,7 +54,6 @@ exit 0
5554

5655
# BUILD_OUTPUT
5756
prog 1.0.0
58-
nobody <nobody@example.com>
5957
How to use multiline help text
6058

6159
Extra lines after the comment tag accepts description, which don't start with an `@`,

tests/snapshots/integration__multiline__wrap2.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ prog foo -h
88
# OUTPUT
99
command cat >&2 <<-'EOF'
1010
prog 1.0.0
11-
nobody <nobody@example.com>
1211
How to use multiline help text
1312

1413
Extra lines after the comment tag accepts description, which don't start with
@@ -55,7 +54,6 @@ exit 0
5554

5655
# BUILD_OUTPUT
5756
prog 1.0.0
58-
nobody <nobody@example.com>
5957
How to use multiline help text
6058

6159
Extra lines after the comment tag accepts description, which don't start with an `@`,

0 commit comments

Comments
 (0)