Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9b06986
Feat(git_utils): add update method for comment
aragami3070 Aug 23, 2025
6983396
Feat(cli_parse): add handle_update for handle_comment
aragami3070 Aug 23, 2025
0f00228
Fix(cli_out): not printing pull request in issues print
aragami3070 Aug 23, 2025
90ec07e
Feat(cli_parse): add update command and handle for comment
aragami3070 Aug 23, 2025
412c035
Feat(cli_parse): add entities mod with CreateRepoArgs struct
aragami3070 Aug 23, 2025
7c4e9b2
Chore(repo): add usage CreateRepoArgs
aragami3070 Aug 23, 2025
50a4d0a
Chore(repo): add usage CreateRepoArgs for create in org
aragami3070 Aug 23, 2025
12ad947
Chore(cli_in): change ToString trait to Display for IssuesListStates …
aragami3070 Aug 23, 2025
1b80dcb
Chore: cargo clippy fixes
aragami3070 Aug 23, 2025
ce9e456
Feat(entities): add ListIssueArgs struct
aragami3070 Aug 23, 2025
42511ae
Chore(issue): add usage ListIssueArgs
aragami3070 Aug 23, 2025
d744230
Feat(entities): add UpdateIssueArgs struct
aragami3070 Aug 23, 2025
03ffa61
Chore(issue): add usage UpdateIssueArgs
aragami3070 Aug 23, 2025
adfdce3
Feat(entities): add CreateRepoFromTemplateArgs struct
aragami3070 Aug 23, 2025
c04ebd1
Chore(repo): add usage CreateRepoFromTemplateArgs
aragami3070 Aug 23, 2025
99eb3b1
Feat(entities): add CreateReleaseArgs struct
aragami3070 Aug 23, 2025
ddf781a
Chore(release): add usage CreateReleaseArgs
aragami3070 Aug 23, 2025
2c814a4
Chore: cargo fmt fixes
aragami3070 Aug 23, 2025
ca67a6f
Chore(readme): update road map
aragami3070 Aug 23, 2025
8750223
Feat(cargo): update package version
aragami3070 Aug 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "github-cli"
version = "1.13.0"
version = "1.14.0"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ github-cli release --help
- [x] Сделать создание комментария в issue/pull request
- [x] Сделать получение комментариев для issue/pull request
- [x] Сделать получение review комментариев для pull request
- [ ] Сделать редактирование комментария для issue/pull request
- [x] Сделать редактирование комментария для issue/pull request
- [ ] Сделать удаление комментария для issue/pull request

### issue
Expand Down
16 changes: 16 additions & 0 deletions src/cli_in/comment_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,20 @@ pub enum CommentCommand {
#[clap(long, default_value = "desc")]
order: Orders,
},

/// Update comment for issue/pull request by comment id
Update {
/// Repo owner (optional)
#[clap(long, short, default_value = None)]
owner: Option<RepoOwner>,
/// Repo name (optional)
#[clap(long, short, default_value = None)]
repo: Option<RepoName>,
/// Update comment from issue/pull request by id
#[clap(long, short)]
comment_id: i64,
/// Comment body (optional)
#[clap(long, short, default_value = "")]
body: String,
},
}
12 changes: 6 additions & 6 deletions src/cli_in/issue_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ pub enum IssueCommand {
iss_on_page: i64,
},

/// Get issue by number
Get {
/// Get issue by number
Get {
/// Repo owner (optional)
#[clap(long, short, default_value = None)]
owner: Option<RepoOwner>,
Expand All @@ -44,10 +44,10 @@ pub enum IssueCommand {
/// Get issue with number
#[clap(long, short)]
number: i64,
},
},

/// Get issue with comment from issues list
GetFromList {
/// Get issue with comment from issues list
GetFromList {
/// Repo owner (optional)
#[clap(long, short, default_value = None)]
owner: Option<RepoOwner>,
Expand All @@ -72,7 +72,7 @@ pub enum IssueCommand {
/// Results on page (max 100) (optional)
#[clap(long, short, default_value = "30", value_parser = clap::value_parser!(i64).range(1..=100))]
iss_on_page: i64,
},
},

/// Create issue
Create {
Expand Down
14 changes: 7 additions & 7 deletions src/cli_in/set_vars.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::str::FromStr;
use std::{fmt::Display, str::FromStr};

use octorust::types::{
IssuesListState, Order, ReposCreateInOrgRequestVisibility, ReposListOrgSort, ReposListOrgType,
Expand Down Expand Up @@ -127,13 +127,13 @@ impl FromStr for IssuesListStates {
}
}

impl ToString for IssuesListStates {
fn to_string(&self) -> String {
impl Display for IssuesListStates {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.0 {
IssuesListState::Open => String::from("open"),
IssuesListState::Closed => String::from("closed"),
IssuesListState::All => String::from("all"),
IssuesListState::FallthroughString => String::from("FallthroughString"),
IssuesListState::Open => write!(f, "open"),
IssuesListState::Closed => write!(f, "closed"),
IssuesListState::All => write!(f, "all"),
IssuesListState::FallthroughString => write!(f, "FallthroughString"),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli_out/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod print_in_cli;
pub mod fuzzy_select;
pub mod print_in_cli;
61 changes: 39 additions & 22 deletions src/cli_out/print_in_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct PrintError {
enum PrintErrorKind {
/// Github response was wrong
BadResponse,
/// Trying get pull request data from issue command
NotIssue,
}

impl Error for PrintError {}
Expand All @@ -27,6 +29,12 @@ impl fmt::Display for PrintError {
&self.description
)
}
PrintErrorKind::NotIssue => {
write!(
f,
"you tried get pull request from issue command.\n Please use pull request commands"
)
}
}
}
}
Expand Down Expand Up @@ -58,24 +66,31 @@ pub fn print_issues(list_issues: Vec<IssueSimple>, state: IssuesListStates, numb
);
println!();
for issue in list_issues {
if issue.pull_request.is_some() {
continue;
}
println!("╭────────────────────────────────────────────────────────────────────────────────────────────────");
println!(" Issue {}: {};", issue.number, issue.title);
println!(" Body: {}", issue.body);
println!(" labels:");
for label in issue.labels {
println!(" {}: {}", label.name, label.description);
}
match issue.created_at {
Some(time) => {
println!(" Created at: {}", time);
}
None => {}

if let Some(time) = issue.created_at {
println!(" Created at: {time}");
};
println!("╰────────────────────────────────────────────────────────────────────────────────────────────────");
}
}

pub fn print_simple_issue(issue: IssueSimple) {
pub fn print_simple_issue(issue: IssueSimple) -> Result<(), Box<dyn Error>> {
if issue.pull_request.is_some() {
return Err(Box::new(PrintError {
kind: PrintErrorKind::NotIssue,
description: "Trying get pull request from issue command".to_string(),
}));
}
println!("╭────────────────────────────────────────────────────────────────────────────────────────────────");
println!(" Issue {}: {};", issue.number, issue.title);
println!(" State: {}", issue.state);
Expand All @@ -84,36 +99,38 @@ pub fn print_simple_issue(issue: IssueSimple) {
for label in issue.labels {
println!(" {}: {}", label.name, label.description);
}
match issue.created_at {
Some(time) => {
println!(" Created at: {}", time);
}
None => {}

if let Some(time) = issue.created_at {
println!(" Created at: {time}");
};
println!("╰────────────────────────────────────────────────────────────────────────────────────────────────");
Ok(())
}

pub fn print_issue(issue: Issue) {
pub fn print_issue(issue: Issue) -> Result<(), Box<dyn Error>> {
if issue.pull_request.is_some() {
return Err(Box::new(PrintError {
kind: PrintErrorKind::NotIssue,
description: "Trying get pull request from issue command".to_string(),
}));
}

println!("╭────────────────────────────────────────────────────────────────────────────────────────────────");
println!(" Issue {}: {};", issue.number, issue.title);
println!(" State: {}", issue.state);
println!(" Body: {}", issue.body);
println!(" labels:");
for label in issue.labels {
match label.labels_data() {
Some(data) => {
println!(" {}: {}", data.name, data.description);
}
None => {}
if let Some(data) = label.labels_data() {
println!(" {}: {}", data.name, data.description);
}
}
match issue.created_at {
Some(time) => {
println!(" Created at: {}", time);
}
None => {}

if let Some(time) = issue.created_at {
println!(" Created at: {time}");
};
println!("╰────────────────────────────────────────────────────────────────────────────────────────────────");
Ok(())
}

pub fn print_url(result: String, description: &str) {
Expand Down
52 changes: 52 additions & 0 deletions src/cli_parse/entities.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use crate::cli_in::set_vars::{IssuesListStates, States};

pub struct ListIssueArgs {
pub creator: String,
pub assignee: String,
pub state: IssuesListStates,
pub labels: String,
pub numb_of_page: i64,
pub iss_on_page: i64,
}

pub struct UpdateIssueArgs {
pub title: Option<String>,
pub body: Option<String>,
pub number: i64,
pub state: States,
}

pub struct CreateRepoArgs {
pub allow_auto_merge: Option<bool>,
pub allow_merge_commit: Option<bool>,
pub allow_rebase_merge: Option<bool>,
pub allow_squash_merge: Option<bool>,
pub auto_init: Option<bool>,
pub delete_branch_on_merge: Option<bool>,
pub has_issues: Option<bool>,
pub has_projects: Option<bool>,
pub has_wiki: Option<bool>,
pub is_template: Option<bool>,
pub private: Option<bool>,
pub description: String,
pub gitignore_template: String,
pub homepage: String,
pub license_template: String,
pub name: String,
}

pub struct CreateRepoFromTemplateArgs {
pub description: String,
pub include_all_branches: Option<bool>,
pub private: Option<bool>,
}

pub struct CreateReleaseArgs {
pub body: String,
pub name: String,
pub discussion_category_name: String,
pub tag_name: String,
pub draft: Option<bool>,
pub prerelease: Option<bool>,
pub target_commitish: String,
}
8 changes: 4 additions & 4 deletions src/cli_parse/handle_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ pub async fn handle_cli_command(args: Args, github_client: Client) -> Result<(),
match args.command {
CliCommand::Issue { subcommand } => {
handle_issue_command(github_client, subcommand).await?;
Ok(())
Ok(())
}

CliCommand::Comment { subcommand } => {
handle_comment_command(github_client, subcommand).await?;
Ok(())
Ok(())
}

CliCommand::Repo { subcommand } => {
handle_repo_command(github_client, subcommand).await?;
Ok(())
Ok(())
}

CliCommand::Release { subcommand } => {
handle_release_command(github_client, subcommand).await?;
Ok(())
Ok(())
}
}
}
28 changes: 28 additions & 0 deletions src/cli_parse/handle_commands/handle_comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ pub async fn handle_comment_command(
handle_get_all_from_review(github_client, owner, repo, number, sort, order).await?;
Ok(())
}

CommentCommand::Update {
owner,
repo,
comment_id,
body,
} => {
handle_update(github_client, owner, repo, comment_id, body).await?;

Ok(())
}
}
}

Expand Down Expand Up @@ -116,3 +127,20 @@ async fn handle_get_all_from_review(
print_review_comments(result)?;
Ok(())
}

async fn handle_update(
github_client: Client,
owner: Option<RepoOwner>,
repo: Option<RepoName>,
comment_id: i64,
body: String,
) -> Result<(), Box<dyn Error>> {
let repo_info = match owner {
Some(_) => RepoInfo::new(Repo::Input, owner, repo)?,
None => RepoInfo::new(Repo::Current, None, None)?,
};
let result = comments::update(&github_client, &repo_info, &comment_id, &body).await?;

println!("{result}");
Ok(())
}
Loading