diff --git a/Cargo.lock b/Cargo.lock index da19160..18b0bac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1115,7 +1115,7 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "notecli" -version = "0.3.1" +version = "0.4.0" dependencies = [ "android-native-keyring-store", "apple-native-keyring-store", diff --git a/Cargo.toml b/Cargo.toml index 3784256..a9df10b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "notecli" -version = "0.3.1" +version = "0.4.0" edition = "2021" description = "Headless Misskey client — CLI & library" repository = "https://github.com/hitalin/notecli" diff --git a/README.md b/README.md index c3cd5fe..6c0fc5b 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ cargo install --git https://github.com/hitalin/notecli.git notecli login misskey.io # 2. タイムラインを見る -notecli tl +notecli timeline # 3. ノートを投稿 notecli post "Hello from notecli!" diff --git a/src/cli.rs b/src/cli.rs index 4156a05..b69d49b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -79,13 +79,13 @@ pub fn command_metadata() -> Vec { 使用例:\n\ \x20 notecli login misskey.io\n\ \x20 notecli post \"Hello, world!\"\n\ - \x20 notecli tl home -l 10\n\ + \x20 notecli timeline home -l 10\n\ \x20 notecli react \":star:\"\n\n\ Unix ツール連携:\n\ - \x20 notecli tl -c | fzf --with-nth=2.. | cut -f1 | xargs -I{} notecli react {} :star:\n\ - \x20 notecli tl --ids -l 5 | xargs -I{} notecli react {} :thumbsup:\n\ - \x20 notecli tl --jsonl | jq -r 'select(.user.username == \"taka\") | .id'\n\ - \x20 notecli tl -c -l 100 | grep \"Rust\" | cut -f1" + \x20 notecli timeline -c | fzf --with-nth=2.. | cut -f1 | xargs -I{} notecli react {} :star:\n\ + \x20 notecli timeline --ids -l 5 | xargs -I{} notecli react {} :thumbsup:\n\ + \x20 notecli timeline --jsonl | jq -r 'select(.user.username == \"taka\") | .id'\n\ + \x20 notecli timeline -c -l 100 | grep \"Rust\" | cut -f1" )] pub struct Cli { /// 操作するアカウントを指定 (形式: @user@host, アカウントID, ユーザー名) @@ -212,11 +212,11 @@ pub enum Commands { \x20 social - ソーシャルタイムライン(ローカル + フォロー中)\n\ \x20 global - グローバルタイムライン(連合の全投稿)", after_long_help = "使用例:\n\ - \x20 notecli tl\n\ - \x20 notecli tl local -l 10\n\ - \x20 notecli tl -c | fzf --with-nth=2.. | cut -f1" + \x20 notecli timeline\n\ + \x20 notecli timeline local -l 10\n\ + \x20 notecli timeline -c | fzf --with-nth=2.. | cut -f1" )] - Tl { + Timeline { /// タイムラインの種類: home, local, social, global #[arg(default_value = "home")] r#type: String, @@ -322,7 +322,7 @@ pub enum Commands { \x20 notecli react 9abcdef123 \":star:\"\n\ \x20 notecli react 9abcdef123 \"👍\"\n\n\ バッチ:\n\ - \x20 notecli tl --ids -l 5 | xargs -I{} notecli react {} :star:" + \x20 notecli timeline --ids -l 5 | xargs -I{} notecli react {} :star:" )] React { /// 対象ノートID @@ -473,26 +473,26 @@ mod tests { } #[test] - fn parse_tl_default() { - let cli = Cli::parse_from(["notecli", "tl"]); + fn parse_timeline_default() { + let cli = Cli::parse_from(["notecli", "timeline"]); match cli.command.unwrap() { - Commands::Tl { r#type, limit } => { + Commands::Timeline { r#type, limit } => { assert_eq!(r#type, "home"); assert_eq!(limit, 20); } - _ => panic!("Expected Tl command"), + _ => panic!("Expected Timeline command"), } } #[test] - fn parse_tl_with_options() { - let cli = Cli::parse_from(["notecli", "tl", "local", "-l", "10"]); + fn parse_timeline_with_options() { + let cli = Cli::parse_from(["notecli", "timeline", "local", "-l", "10"]); match cli.command.unwrap() { - Commands::Tl { r#type, limit } => { + Commands::Timeline { r#type, limit } => { assert_eq!(r#type, "local"); assert_eq!(limit, 10); } - _ => panic!("Expected Tl command"), + _ => panic!("Expected Timeline command"), } } @@ -512,13 +512,13 @@ mod tests { #[test] fn parse_global_account_option() { - let cli = Cli::parse_from(["notecli", "-a", "@taka@misskey.io", "tl"]); + let cli = Cli::parse_from(["notecli", "-a", "@taka@misskey.io", "timeline"]); assert_eq!(cli.account.as_deref(), Some("@taka@misskey.io")); } #[test] fn parse_output_format_json() { - let cli = Cli::parse_from(["notecli", "--json", "tl"]); + let cli = Cli::parse_from(["notecli", "--json", "timeline"]); assert!(cli.json); assert!(!cli.compact); assert!(!cli.ids); @@ -527,31 +527,31 @@ mod tests { #[test] fn parse_output_format_compact() { - let cli = Cli::parse_from(["notecli", "-c", "tl"]); + let cli = Cli::parse_from(["notecli", "-c", "timeline"]); assert!(cli.compact); } #[test] fn parse_output_format_ids() { - let cli = Cli::parse_from(["notecli", "--ids", "tl"]); + let cli = Cli::parse_from(["notecli", "--ids", "timeline"]); assert!(cli.ids); } #[test] fn parse_output_format_jsonl() { - let cli = Cli::parse_from(["notecli", "--jsonl", "tl"]); + let cli = Cli::parse_from(["notecli", "--jsonl", "timeline"]); assert!(cli.jsonl); } #[test] fn parse_color_option() { - let cli = Cli::parse_from(["notecli", "--color", "never", "tl"]); + let cli = Cli::parse_from(["notecli", "--color", "never", "timeline"]); assert_eq!(cli.color, ColorWhen::Never); } #[test] fn color_defaults_to_auto() { - let cli = Cli::parse_from(["notecli", "tl"]); + let cli = Cli::parse_from(["notecli", "timeline"]); assert_eq!(cli.color, ColorWhen::Auto); } @@ -614,7 +614,7 @@ mod tests { assert!(names.contains(&"accounts")); assert!(names.contains(&"login")); assert!(names.contains(&"post")); - assert!(names.contains(&"tl")); + assert!(names.contains(&"timeline")); assert!(names.contains(&"search")); assert!(names.contains(&"react")); assert!(names.contains(&"user")); diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 560461d..da1af40 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -65,7 +65,7 @@ pub async fn run_cli( } => { notes::run_post(&ctx, text, cw.as_deref(), visibility, reply_to.as_deref(), *local_only).await } - Commands::Tl { r#type, limit } => notes::run_tl(&ctx, r#type, *limit).await, + Commands::Timeline { r#type, limit } => notes::run_timeline(&ctx, r#type, *limit).await, Commands::Search { query, limit } => notes::run_search(&ctx, query, *limit).await, Commands::Note { id } => notes::run_note(&ctx, id).await, Commands::Replies { id, limit } => notes::run_replies(&ctx, id, *limit).await, diff --git a/src/commands/notes.rs b/src/commands/notes.rs index f0d802d..6e93854 100644 --- a/src/commands/notes.rs +++ b/src/commands/notes.rs @@ -43,7 +43,7 @@ pub async fn run_post( Ok(()) } -pub async fn run_tl(ctx: &CmdContext, tl_type: &str, limit: i64) -> Result<(), NoteDeckError> { +pub async fn run_timeline(ctx: &CmdContext, tl_type: &str, limit: i64) -> Result<(), NoteDeckError> { let notes = ctx .client .get_timeline(