Skip to content

Commit ce4d8e2

Browse files
committed
Rename protocol to proto
This affects both the command line option as well as the config file.
1 parent a7fe5ec commit ce4d8e2

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,13 @@ tag = "1.9.0"
260260
#### Cloning with Git or SSH protocols
261261

262262
GitHub and Gist sources are cloned using HTTPS by default. You can specify that
263-
Git or SSH should be used by setting the `protocol` field to the protocol type.
263+
Git or SSH should be used by setting the `proto` field to the protocol type.
264264
This must be one of `git`, `https`, or `ssh`.
265265

266266
```toml
267267
[plugins.pure]
268268
github = "sindresorhus/pure"
269-
protocol = "ssh"
269+
proto = "ssh"
270270
```
271271

272272
For a plain Git source you should specify the URL with a `git://` or `ssh://`

src/cli.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct Add {
5757

5858
/// The Git protocol for a Gist or GitHub plugin.
5959
#[structopt(long, value_name = "PROTO", conflicts_with_all = &["git", "remote", "local"])]
60-
protocol: Option<GitProtocol>,
60+
proto: Option<GitProtocol>,
6161

6262
/// Checkout the tip of a branch.
6363
#[structopt(
@@ -210,7 +210,7 @@ impl Plugin {
210210
github,
211211
remote,
212212
local,
213-
protocol,
213+
proto,
214214
branch,
215215
rev,
216216
tag,
@@ -238,7 +238,7 @@ impl Plugin {
238238
remote,
239239
local,
240240
inline: None,
241-
protocol,
241+
proto,
242242
reference,
243243
directory,
244244
uses,
@@ -520,7 +520,7 @@ OPTIONS:
520520
--github <REPO> Add a clonable GitHub repository
521521
--remote <URL> Add a downloadable file
522522
--local <DIR> Add a local directory
523-
--protocol <PROTO> The Git protocol for a Gist or GitHub plugin
523+
--proto <PROTO> The Git protocol for a Gist or GitHub plugin
524524
--branch <BRANCH> Checkout the tip of a branch
525525
--rev <SHA> Checkout a specific commit
526526
--tag <TAG> Checkout a specific tag
@@ -579,7 +579,7 @@ ARGS:
579579
github: None,
580580
remote: None,
581581
local: None,
582-
protocol: None,
582+
proto: None,
583583
branch: None,
584584
rev: Some("ad149784a1538291f2477fb774eeeed4f4d29e45".into()),
585585
tag: None,
@@ -601,7 +601,7 @@ ARGS:
601601
"579d02802b1cc17baed07753d09f5009",
602602
"--tag",
603603
"0.1.0",
604-
"--protocol",
604+
"--proto",
605605
"ssh",
606606
"--directory",
607607
"missing",
@@ -620,7 +620,7 @@ ARGS:
620620
github: None,
621621
remote: None,
622622
local: None,
623-
protocol: Some("ssh".parse().unwrap()),
623+
proto: Some("ssh".parse().unwrap()),
624624
branch: None,
625625
rev: None,
626626
tag: Some("0.1.0".into()),
@@ -642,7 +642,7 @@ ARGS:
642642
"rossmacarthur/sheldon-test",
643643
"--branch",
644644
"feature",
645-
"--protocol",
645+
"--proto",
646646
"https",
647647
"--directory",
648648
"missing",
@@ -661,7 +661,7 @@ ARGS:
661661
github: Some("rossmacarthur/sheldon-test".parse().unwrap()),
662662
remote: None,
663663
local: None,
664-
protocol: Some("https".parse().unwrap()),
664+
proto: Some("https".parse().unwrap()),
665665
branch: Some("feature".into()),
666666
rev: None,
667667
tag: None,
@@ -696,7 +696,7 @@ ARGS:
696696
github: None,
697697
remote: Some("https://raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh".parse().unwrap()),
698698
local: None,
699-
protocol: None,
699+
proto: None,
700700
branch: None,
701701
rev: None,
702702
tag: None,
@@ -731,7 +731,7 @@ ARGS:
731731
github: None,
732732
remote: None,
733733
local: Some("~/.dotfiles/zsh/pure".into()),
734-
protocol: None,
734+
proto: None,
735735
branch: None,
736736
rev: None,
737737
tag: None,
@@ -802,7 +802,7 @@ ARGS:
802802
"test",
803803
"--git",
804804
"https://github.com/rossmacarthur/sheldon-test",
805-
"--protocol",
805+
"--proto",
806806
"ssh",
807807
])
808808
.kind,
@@ -819,7 +819,7 @@ ARGS:
819819
"test",
820820
"--remote",
821821
"https://raw.githubusercontent.com/rossmacarthur/sheldon-test/master/test.plugin.zsh",
822-
"--protocol",
822+
"--proto",
823823
"ssh",
824824
])
825825
.kind,
@@ -836,7 +836,7 @@ ARGS:
836836
"test",
837837
"--local",
838838
"~/.dotfiles/zsh/pure",
839-
"--protocol",
839+
"--proto",
840840
"ssh",
841841
])
842842
.kind,

src/config.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ pub struct RawPlugin {
106106
/// An inline script.
107107
pub inline: Option<String>,
108108
/// What protocol to use when cloning a repository.
109-
pub protocol: Option<GitProtocol>,
109+
#[serde(alias = "protocol")]
110+
pub proto: Option<GitProtocol>,
110111
/// The Git reference to checkout.
111112
#[serde(flatten)]
112113
pub reference: Option<GitReference>,
@@ -523,7 +524,7 @@ impl RawPlugin {
523524
remote,
524525
local,
525526
inline,
526-
protocol,
527+
proto,
527528
reference,
528529
directory,
529530
uses,
@@ -542,7 +543,7 @@ impl RawPlugin {
542543
(None, Some(repository), None, None, None, None) => {
543544
let url_str = format!(
544545
"{}{}/{}",
545-
protocol.unwrap_or(GitProtocol::Https).prefix(),
546+
proto.unwrap_or(GitProtocol::Https).prefix(),
546547
GIST_HOST,
547548
repository.identifier
548549
);
@@ -554,7 +555,7 @@ impl RawPlugin {
554555
(None, None, Some(repository), None, None, None) => {
555556
let url_str = format!(
556557
"{}{}/{}",
557-
protocol.unwrap_or(GitProtocol::Https).prefix(),
558+
proto.unwrap_or(GitProtocol::Https).prefix(),
558559
GITHUB_HOST,
559560
repository
560561
);
@@ -587,8 +588,8 @@ impl RawPlugin {
587588
"the `branch`, `tag`, and `rev` fields are not supported by this plugin \
588589
type"
589590
);
590-
} else if protocol.is_some() && !is_gist_or_github {
591-
bail!("the `protocol` field is not supported by this plugin type");
591+
} else if proto.is_some() && !is_gist_or_github {
592+
bail!("the `proto` field is not supported by this plugin type");
592593
}
593594

594595
validate_template_names(&apply, templates)?;
@@ -603,7 +604,7 @@ impl RawPlugin {
603604
}
604605
TempSource::Inline(raw) => {
605606
let unsupported = [
606-
("`protocol` field is", protocol.is_some()),
607+
("`proto` field is", proto.is_some()),
607608
("`branch`, `tag`, and `rev` fields are", is_reference_some),
608609
("`directory` field is", directory.is_some()),
609610
("`use` field is", uses.is_some()),
@@ -944,7 +945,7 @@ mod tests {
944945
.parse()
945946
.unwrap(),
946947
),
947-
protocol: Some(GitProtocol::Git),
948+
proto: Some(GitProtocol::Git),
948949
..Default::default()
949950
};
950951
assert_eq!(
@@ -997,7 +998,7 @@ mod tests {
997998
.parse()
998999
.unwrap(),
9991000
),
1000-
protocol: Some(GitProtocol::Ssh),
1001+
proto: Some(GitProtocol::Ssh),
10011002
..Default::default()
10021003
};
10031004
assert_eq!(
@@ -1024,7 +1025,7 @@ mod tests {
10241025
owner: "rossmacarthur".to_string(),
10251026
name: "sheldon-test".to_string(),
10261027
}),
1027-
protocol: Some(GitProtocol::Git),
1028+
proto: Some(GitProtocol::Git),
10281029
..Default::default()
10291030
};
10301031
assert_eq!(
@@ -1077,7 +1078,7 @@ mod tests {
10771078
owner: "rossmacarthur".to_string(),
10781079
name: "sheldon-test".to_string(),
10791080
}),
1080-
protocol: Some(GitProtocol::Ssh),
1081+
proto: Some(GitProtocol::Ssh),
10811082
..Default::default()
10821083
};
10831084
assert_eq!(
@@ -1139,15 +1140,15 @@ mod tests {
11391140
)
11401141
.unwrap(),
11411142
),
1142-
protocol: Some(GitProtocol::Https),
1143+
proto: Some(GitProtocol::Https),
11431144
..Default::default()
11441145
};
11451146
let error = raw_plugin
11461147
.normalize("test".to_string(), &IndexMap::new())
11471148
.unwrap_err();
11481149
assert_eq!(
11491150
error.to_string(),
1150-
"the `protocol` field is not supported by this plugin type"
1151+
"the `proto` field is not supported by this plugin type"
11511152
);
11521153
}
11531154

tests/cases/github_git

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# plugins.toml
22
[plugins.test]
33
github = "rossmacarthur/sheldon-test"
4-
protocol = "git"
4+
proto = "git"
55

66
# plugins.lock
77
version = "<version>"

0 commit comments

Comments
 (0)