cli: Remove `rad push` command

Users should use `git push` or `git push rad` instead.
This commit is contained in:
Alexis Sellier 2023-04-24 13:22:21 +02:00
parent 671c169244
commit a285943166
No known key found for this signature in database
12 changed files with 11 additions and 138 deletions

View File

@ -18,7 +18,7 @@ Your project id is rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji. You can show it any time b
rad .
To publish your project to the network, run:
rad push
git push
```

View File

@ -34,7 +34,7 @@ master <- z6MknSL…StBU8Vi/flux-capacitor-power (3e674d1)
✓ Patch 191a14e520f2eeff7c0e3ee0a5523c5217eecb89 created 🌱
To publish your patch to the network, run:
rad push
git push rad
```
It will now be listed as one of the project's open patches.

View File

@ -18,7 +18,7 @@ Your project id is rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji. You can show it any time b
rad .
To publish your project to the network, run:
rad push
git push
```

View File

@ -34,7 +34,7 @@ master <- z6Mkt67…v4N1tRk/flux-capacitor-power (3e674d1)
✓ Patch a07ef7743a32a2e902672ea3526d1db6ee08108a created 🌱
To publish your patch to the network, run:
rad push
git push rad
```
It will now be listed as one of the project's open patches.

View File

@ -70,7 +70,7 @@ Fast-forward
create mode 100644 README.md
create mode 100644 REQUIREMENTS.md
✓ Updated master f2de534 -> f6484e0 via fast-forward
✓ Patch state updated, use `rad push` to publish
✓ Patch state updated, use `git push rad` to publish
```
The patch is now merged and closed :).

View File

@ -36,8 +36,6 @@ pub mod rad_node;
pub mod rad_patch;
#[path = "commands/path.rs"]
pub mod rad_path;
#[path = "commands/push.rs"]
pub mod rad_push;
#[path = "commands/remote.rs"]
pub mod rad_remote;
#[path = "commands/review.rs"]

View File

@ -30,7 +30,6 @@ const COMMANDS: &[Help] = &[
rad_node::HELP,
rad_patch::HELP,
rad_path::HELP,
rad_push::HELP,
rad_review::HELP,
rad_rm::HELP,
rad_self::HELP,

View File

@ -206,6 +206,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
let mut node = radicle::Node::new(profile.socket());
let mut spinner = term::spinner("Initializing...");
let mut push_cmd = String::from("git push");
match radicle::rad::init(
&repo,
@ -242,6 +243,8 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
proj.default_branch(),
&radicle::git::refs::workdir::branch(proj.default_branch()),
)?;
} else {
push_cmd = format!("git push {}", *radicle::rad::REMOTE_NAME);
}
if options.setup_signing {
@ -277,7 +280,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
if !options.announce {
term::blank();
term::info!("To publish your project to the network, run:");
term::indented(term::format::secondary("rad push"));
term::indented(term::format::secondary(push_cmd));
}
term::blank();
}

View File

@ -298,7 +298,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
term::success!(
"Patch state updated, use {} to publish",
term::format::secondary("`rad push`")
term::format::secondary("`git push rad`")
);
Ok(())

View File

@ -132,7 +132,7 @@ pub fn run(
}
} else {
term::info!("To publish your patch to the network, run:");
term::indented(term::format::secondary("rad push"));
term::indented(term::format::secondary("git push rad"));
}
Ok(())

View File

@ -1,119 +0,0 @@
use std::ffi::OsString;
use std::path::Path;
use anyhow::anyhow;
use radicle::git;
use crate::terminal as term;
use crate::terminal::args::{Args, Error, Help};
pub const HELP: Help = Help {
name: "push",
description: "Publish a project to the network",
version: env!("CARGO_PKG_VERSION"),
usage: r#"
Usage
rad push [<option>...]
By default, only the current branch is pushed.
Options
--all Push all branches (default: false)
--help Print help
Git options
-f, --force Force push
-u, --set-upstream Set upstream tracking branch
"#,
};
#[derive(Default, Debug)]
pub struct Options {
pub verbose: bool,
pub force: bool,
pub all: bool,
pub set_upstream: bool,
}
impl Args for Options {
fn from_args(args: Vec<OsString>) -> anyhow::Result<(Self, Vec<OsString>)> {
use lexopt::prelude::*;
let mut parser = lexopt::Parser::from_args(args);
let mut verbose = false;
let mut force = false;
let mut all = false;
let mut set_upstream = false;
while let Some(arg) = parser.next()? {
match arg {
Long("verbose") | Short('v') => {
verbose = true;
}
Long("help") => {
return Err(Error::Help.into());
}
Long("all") => {
all = true;
}
Long("set-upstream") | Short('u') => {
set_upstream = true;
}
Long("force") | Short('f') => {
force = true;
}
arg => {
return Err(anyhow!(arg.unexpected()));
}
}
}
Ok((
Options {
force,
all,
set_upstream,
verbose,
},
vec![],
))
}
}
pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
ctx.profile()?;
term::info!("Pushing 🌱 to remote `rad`");
let cwd = Path::new(".").canonicalize()?;
let mut args = vec!["push"];
if options.force {
args.push("--force");
}
if options.set_upstream {
args.push("--set-upstream");
}
if options.all {
args.push("--all");
}
if options.verbose {
args.push("--verbose");
}
args.push("rad"); // Push to "rad" remote.
term::subcommand(format!("git {}", args.join(" ")));
// Push to storage.
match git::run::<_, _, &str, &str>(cwd, args, []) {
Ok(output) => term::blob(output),
Err(err) => return Err(err.into()),
}
Ok(())
}

View File

@ -259,14 +259,6 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
args.to_vec(),
);
}
"push" => {
term::run_command_args::<rad_push::Options, _>(
rad_push::HELP,
"Push",
rad_push::run,
args.to_vec(),
);
}
"review" => {
term::run_command_args::<rad_review::Options, _>(
rad_review::HELP,