mirror of
https://codeberg.org/Cyborus/forgejo-cli.git
synced 2024-11-10 03:59:31 +01:00
docs: document commands
This commit is contained in:
parent
227a2207fb
commit
72800f9bba
5 changed files with 76 additions and 16 deletions
12
src/auth.rs
12
src/auth.rs
|
@ -3,10 +3,15 @@ use eyre::OptionExt;
|
||||||
|
|
||||||
#[derive(Subcommand, Clone, Debug)]
|
#[derive(Subcommand, Clone, Debug)]
|
||||||
pub enum AuthCommand {
|
pub enum AuthCommand {
|
||||||
|
/// Log in to an instance.
|
||||||
|
///
|
||||||
|
/// Opens an auth page in your browser
|
||||||
Login,
|
Login,
|
||||||
Logout {
|
/// Deletes login info for an instance
|
||||||
host: String,
|
Logout { host: String },
|
||||||
},
|
/// Add an application token for an instance
|
||||||
|
///
|
||||||
|
/// Use this if `fj auth login` doesn't work
|
||||||
AddKey {
|
AddKey {
|
||||||
/// The domain name of the forgejo instance.
|
/// The domain name of the forgejo instance.
|
||||||
host: String,
|
host: String,
|
||||||
|
@ -15,6 +20,7 @@ pub enum AuthCommand {
|
||||||
/// The key to add. If not present, the key will be read in from stdin.
|
/// The key to add. If not present, the key will be read in from stdin.
|
||||||
key: Option<String>,
|
key: Option<String>,
|
||||||
},
|
},
|
||||||
|
/// List all instances you're currently logged into
|
||||||
List,
|
List,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ pub struct IssueCommand {
|
||||||
|
|
||||||
#[derive(Subcommand, Clone, Debug)]
|
#[derive(Subcommand, Clone, Debug)]
|
||||||
pub enum IssueSubcommand {
|
pub enum IssueSubcommand {
|
||||||
|
/// Create a new issue on a repo
|
||||||
Create {
|
Create {
|
||||||
title: String,
|
title: String,
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
|
@ -26,23 +27,28 @@ pub enum IssueSubcommand {
|
||||||
#[clap(long, short, id = "[HOST/]OWNER/REPO")]
|
#[clap(long, short, id = "[HOST/]OWNER/REPO")]
|
||||||
repo: Option<RepoArg>,
|
repo: Option<RepoArg>,
|
||||||
},
|
},
|
||||||
|
/// Edit an issue
|
||||||
Edit {
|
Edit {
|
||||||
#[clap(id = "[REPO#]ID")]
|
#[clap(id = "[REPO#]ID")]
|
||||||
issue: IssueId,
|
issue: IssueId,
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
command: EditCommand,
|
command: EditCommand,
|
||||||
},
|
},
|
||||||
|
/// Add a comment on an issue
|
||||||
Comment {
|
Comment {
|
||||||
#[clap(id = "[REPO#]ID")]
|
#[clap(id = "[REPO#]ID")]
|
||||||
issue: IssueId,
|
issue: IssueId,
|
||||||
body: Option<String>,
|
body: Option<String>,
|
||||||
},
|
},
|
||||||
|
/// Close an issue
|
||||||
Close {
|
Close {
|
||||||
#[clap(id = "[REPO#]ID")]
|
#[clap(id = "[REPO#]ID")]
|
||||||
issue: IssueId,
|
issue: IssueId,
|
||||||
|
/// A comment to leave on the issue before closing it
|
||||||
#[clap(long, short)]
|
#[clap(long, short)]
|
||||||
with_msg: Option<Option<String>>,
|
with_msg: Option<Option<String>>,
|
||||||
},
|
},
|
||||||
|
/// Search for an issue in a repo
|
||||||
Search {
|
Search {
|
||||||
#[clap(long, short, id = "[HOST/]OWNER/REPO")]
|
#[clap(long, short, id = "[HOST/]OWNER/REPO")]
|
||||||
repo: Option<RepoArg>,
|
repo: Option<RepoArg>,
|
||||||
|
@ -56,12 +62,14 @@ pub enum IssueSubcommand {
|
||||||
#[clap(long, short)]
|
#[clap(long, short)]
|
||||||
state: Option<State>,
|
state: Option<State>,
|
||||||
},
|
},
|
||||||
|
/// View an issue's info
|
||||||
View {
|
View {
|
||||||
#[clap(id = "[REPO#]ID")]
|
#[clap(id = "[REPO#]ID")]
|
||||||
id: IssueId,
|
id: IssueId,
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
command: Option<ViewCommand>,
|
command: Option<ViewCommand>,
|
||||||
},
|
},
|
||||||
|
/// Open an issue in your browser
|
||||||
Browse {
|
Browse {
|
||||||
#[clap(id = "[REPO#]ID")]
|
#[clap(id = "[REPO#]ID")]
|
||||||
id: IssueId,
|
id: IssueId,
|
||||||
|
@ -135,12 +143,11 @@ impl From<State> for forgejo_api::structs::IssueListIssuesQueryState {
|
||||||
|
|
||||||
#[derive(Subcommand, Clone, Debug)]
|
#[derive(Subcommand, Clone, Debug)]
|
||||||
pub enum EditCommand {
|
pub enum EditCommand {
|
||||||
Title {
|
/// Edit an issue's title
|
||||||
new_title: Option<String>,
|
Title { new_title: Option<String> },
|
||||||
},
|
/// Edit an issue's text content
|
||||||
Body {
|
Body { new_body: Option<String> },
|
||||||
new_body: Option<String>,
|
/// Edit a comment on an issue
|
||||||
},
|
|
||||||
Comment {
|
Comment {
|
||||||
idx: usize,
|
idx: usize,
|
||||||
new_body: Option<String>,
|
new_body: Option<String>,
|
||||||
|
@ -149,8 +156,11 @@ pub enum EditCommand {
|
||||||
|
|
||||||
#[derive(Subcommand, Clone, Debug)]
|
#[derive(Subcommand, Clone, Debug)]
|
||||||
pub enum ViewCommand {
|
pub enum ViewCommand {
|
||||||
|
/// View an issue's title and body. The default
|
||||||
Body,
|
Body,
|
||||||
|
/// View a specific
|
||||||
Comment { idx: usize },
|
Comment { idx: usize },
|
||||||
|
/// List every comment
|
||||||
Comments,
|
Comments,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ pub struct ReleaseCommand {
|
||||||
|
|
||||||
#[derive(Subcommand, Clone, Debug)]
|
#[derive(Subcommand, Clone, Debug)]
|
||||||
pub enum ReleaseSubcommand {
|
pub enum ReleaseSubcommand {
|
||||||
|
/// Create a new release
|
||||||
Create {
|
Create {
|
||||||
name: String,
|
name: String,
|
||||||
#[clap(long, short = 'T')]
|
#[clap(long, short = 'T')]
|
||||||
|
@ -56,6 +57,7 @@ pub enum ReleaseSubcommand {
|
||||||
#[clap(long, short)]
|
#[clap(long, short)]
|
||||||
prerelease: bool,
|
prerelease: bool,
|
||||||
},
|
},
|
||||||
|
/// Edit a release's info
|
||||||
Edit {
|
Edit {
|
||||||
name: String,
|
name: String,
|
||||||
#[clap(long, short = 'n')]
|
#[clap(long, short = 'n')]
|
||||||
|
@ -73,40 +75,45 @@ pub enum ReleaseSubcommand {
|
||||||
#[clap(long, short)]
|
#[clap(long, short)]
|
||||||
prerelease: Option<bool>,
|
prerelease: Option<bool>,
|
||||||
},
|
},
|
||||||
|
/// Delete a release
|
||||||
Delete {
|
Delete {
|
||||||
name: String,
|
name: String,
|
||||||
#[clap(long, short = 't')]
|
#[clap(long, short = 't')]
|
||||||
by_tag: bool,
|
by_tag: bool,
|
||||||
},
|
},
|
||||||
|
/// List all the releases on a repo
|
||||||
List {
|
List {
|
||||||
#[clap(long, short = 'p')]
|
#[clap(long, short = 'p')]
|
||||||
include_prerelease: bool,
|
include_prerelease: bool,
|
||||||
#[clap(long, short = 'd')]
|
#[clap(long, short = 'd')]
|
||||||
include_draft: bool,
|
include_draft: bool,
|
||||||
},
|
},
|
||||||
|
/// View a release's info
|
||||||
View {
|
View {
|
||||||
name: String,
|
name: String,
|
||||||
#[clap(long, short = 't')]
|
#[clap(long, short = 't')]
|
||||||
by_tag: bool,
|
by_tag: bool,
|
||||||
},
|
},
|
||||||
Browse {
|
/// Open a release in your browser
|
||||||
name: Option<String>,
|
Browse { name: Option<String> },
|
||||||
},
|
/// Commands on a release's attached files
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
Asset(AssetCommand),
|
Asset(AssetCommand),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand, Clone, Debug)]
|
#[derive(Subcommand, Clone, Debug)]
|
||||||
pub enum AssetCommand {
|
pub enum AssetCommand {
|
||||||
|
/// Create a new attachment on a release
|
||||||
Create {
|
Create {
|
||||||
release: String,
|
release: String,
|
||||||
path: std::path::PathBuf,
|
path: std::path::PathBuf,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
},
|
},
|
||||||
Delete {
|
/// Remove an attachment from a release
|
||||||
release: String,
|
Delete { release: String, asset: String },
|
||||||
asset: String,
|
/// Download an attached file
|
||||||
},
|
///
|
||||||
|
/// Use `source.zip` or `source.tar.gz` to download the repo archive
|
||||||
Download {
|
Download {
|
||||||
release: String,
|
release: String,
|
||||||
asset: String,
|
asset: String,
|
||||||
|
|
10
src/repo.rs
10
src/repo.rs
|
@ -288,6 +288,7 @@ impl std::fmt::Display for RepoArgError {
|
||||||
|
|
||||||
#[derive(Subcommand, Clone, Debug)]
|
#[derive(Subcommand, Clone, Debug)]
|
||||||
pub enum RepoCommand {
|
pub enum RepoCommand {
|
||||||
|
/// Creates a new repository
|
||||||
Create {
|
Create {
|
||||||
repo: String,
|
repo: String,
|
||||||
|
|
||||||
|
@ -304,6 +305,7 @@ pub enum RepoCommand {
|
||||||
#[clap(long, short)]
|
#[clap(long, short)]
|
||||||
push: bool,
|
push: bool,
|
||||||
},
|
},
|
||||||
|
/// Fork a repository onto your account
|
||||||
Fork {
|
Fork {
|
||||||
#[clap(id = "[HOST/]OWNER/REPO")]
|
#[clap(id = "[HOST/]OWNER/REPO")]
|
||||||
repo: RepoArg,
|
repo: RepoArg,
|
||||||
|
@ -312,29 +314,37 @@ pub enum RepoCommand {
|
||||||
#[clap(long, short = 'R')]
|
#[clap(long, short = 'R')]
|
||||||
remote: Option<String>,
|
remote: Option<String>,
|
||||||
},
|
},
|
||||||
|
/// View a repo's info
|
||||||
View {
|
View {
|
||||||
#[clap(id = "[HOST/]OWNER/REPO")]
|
#[clap(id = "[HOST/]OWNER/REPO")]
|
||||||
name: Option<RepoArg>,
|
name: Option<RepoArg>,
|
||||||
#[clap(long, short = 'R')]
|
#[clap(long, short = 'R')]
|
||||||
remote: Option<String>,
|
remote: Option<String>,
|
||||||
},
|
},
|
||||||
|
/// Clone a repo's code locally
|
||||||
Clone {
|
Clone {
|
||||||
#[clap(id = "[HOST/]OWNER/REPO")]
|
#[clap(id = "[HOST/]OWNER/REPO")]
|
||||||
repo: RepoArg,
|
repo: RepoArg,
|
||||||
path: Option<PathBuf>,
|
path: Option<PathBuf>,
|
||||||
},
|
},
|
||||||
|
/// Add a star to a repo
|
||||||
Star {
|
Star {
|
||||||
#[clap(id = "[HOST/]OWNER/REPO")]
|
#[clap(id = "[HOST/]OWNER/REPO")]
|
||||||
repo: RepoArg,
|
repo: RepoArg,
|
||||||
},
|
},
|
||||||
|
/// Take away a star from a repo
|
||||||
Unstar {
|
Unstar {
|
||||||
#[clap(id = "[HOST/]OWNER/REPO")]
|
#[clap(id = "[HOST/]OWNER/REPO")]
|
||||||
repo: RepoArg,
|
repo: RepoArg,
|
||||||
},
|
},
|
||||||
|
/// Delete a repository
|
||||||
|
///
|
||||||
|
/// This cannot be undone!
|
||||||
Delete {
|
Delete {
|
||||||
#[clap(id = "[HOST/]OWNER/REPO")]
|
#[clap(id = "[HOST/]OWNER/REPO")]
|
||||||
repo: RepoArg,
|
repo: RepoArg,
|
||||||
},
|
},
|
||||||
|
/// Open a repository's page in your browser
|
||||||
Browse {
|
Browse {
|
||||||
#[clap(id = "[HOST/]OWNER/REPO")]
|
#[clap(id = "[HOST/]OWNER/REPO")]
|
||||||
name: Option<RepoArg>,
|
name: Option<RepoArg>,
|
||||||
|
|
27
src/user.rs
27
src/user.rs
|
@ -14,46 +14,66 @@ pub struct UserCommand {
|
||||||
|
|
||||||
#[derive(Subcommand, Clone, Debug)]
|
#[derive(Subcommand, Clone, Debug)]
|
||||||
pub enum UserSubcommand {
|
pub enum UserSubcommand {
|
||||||
|
/// Search for a user by username
|
||||||
Search {
|
Search {
|
||||||
/// The name to search for
|
/// The name to search for
|
||||||
query: String,
|
query: String,
|
||||||
#[clap(long, short)]
|
#[clap(long, short)]
|
||||||
page: Option<usize>,
|
page: Option<usize>,
|
||||||
},
|
},
|
||||||
|
/// View a user's profile page
|
||||||
View {
|
View {
|
||||||
/// The name of the user to view
|
/// The name of the user to view
|
||||||
|
///
|
||||||
|
/// Omit to view your own page
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
},
|
},
|
||||||
|
/// Open a user's profile page in your browser
|
||||||
Browse {
|
Browse {
|
||||||
/// The name of the user to open in your browser
|
/// The name of the user to open in your browser
|
||||||
|
///
|
||||||
|
/// Omit to view your own page
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
},
|
},
|
||||||
|
/// Follow a user
|
||||||
Follow {
|
Follow {
|
||||||
/// The name of the user to follow
|
/// The name of the user to follow
|
||||||
user: String,
|
user: String,
|
||||||
},
|
},
|
||||||
|
/// Unfollow a user
|
||||||
Unfollow {
|
Unfollow {
|
||||||
/// The name of the user to follow
|
/// The name of the user to follow
|
||||||
user: String,
|
user: String,
|
||||||
},
|
},
|
||||||
|
/// List everyone a user's follows
|
||||||
Following {
|
Following {
|
||||||
/// The name of the user whose follows to list
|
/// The name of the user whose follows to list
|
||||||
|
///
|
||||||
|
/// Omit to view your own follows
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
},
|
},
|
||||||
|
/// List a user's followers
|
||||||
Followers {
|
Followers {
|
||||||
/// The name of the user whose followers to list
|
/// The name of the user whose followers to list
|
||||||
|
///
|
||||||
|
/// Omit to view your own followers
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
},
|
},
|
||||||
|
/// Block a user
|
||||||
Block {
|
Block {
|
||||||
/// The name of the user to block
|
/// The name of the user to block
|
||||||
user: String,
|
user: String,
|
||||||
},
|
},
|
||||||
|
/// Unblock a user
|
||||||
Unblock {
|
Unblock {
|
||||||
/// The name of the user to unblock
|
/// The name of the user to unblock
|
||||||
user: String,
|
user: String,
|
||||||
},
|
},
|
||||||
|
/// List a user's repositories
|
||||||
Repos {
|
Repos {
|
||||||
/// The name of the user whose repos to list
|
/// The name of the user whose repos to list
|
||||||
|
///
|
||||||
|
/// Omit to view your own repos.
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
/// List starred repos instead of owned repos
|
/// List starred repos instead of owned repos
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
|
@ -62,14 +82,21 @@ pub enum UserSubcommand {
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
sort: Option<RepoSortOrder>,
|
sort: Option<RepoSortOrder>,
|
||||||
},
|
},
|
||||||
|
/// List the organizations a user is a member of
|
||||||
Orgs {
|
Orgs {
|
||||||
/// The name of the user to view org membership of
|
/// The name of the user to view org membership of
|
||||||
|
///
|
||||||
|
/// Omit to view your own orgs.
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
},
|
},
|
||||||
|
/// List a user's recent activity
|
||||||
Activity {
|
Activity {
|
||||||
/// The name of the user to view the activity of
|
/// The name of the user to view the activity of
|
||||||
|
///
|
||||||
|
/// Omit to view your own activity.
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
},
|
},
|
||||||
|
/// Edit your user settings
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
Edit(EditCommand),
|
Edit(EditCommand),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue