use clap::Subcommand;
use gitflow_core::{
CliOutput,
issue::{CreateIssueArgs, EditIssueArgs, IssueProvider, ListIssueArgs},
types::State,
};
use gitflow_gitcode::GitCodeIssueProvider;
use gitflow_github::GitHubIssueProvider;
use gitflow_gitlab::GitLabIssueProvider;
use crate::{
OutputFormat,
commands::{list_args::validate_limit, output::print_list_output},
};
#[derive(Debug, Subcommand)]
pub enum IssueCommand {
Search(super::query_search::SearchArgs),
Create {
#[arg(long)]
title: String,
#[arg(long)]
body: Option<String>,
#[arg(long = "body-file")]
body_file: Option<String>,
#[arg(long = "label")]
label: Vec<String>,
#[arg(long = "assignee")]
assignee: Vec<String>,
#[arg(long)]
milestone: Option<String>,
#[arg(long)]
repo: Option<String>,
},
Edit {
number: u64,
#[arg(long)]
title: Option<String>,
#[arg(long)]
body: Option<String>,
#[arg(long = "body-file")]
body_file: Option<String>,
#[arg(long)]
milestone: Option<String>,
#[arg(long = "remove-milestone")]
remove_milestone: bool,
},
List {
#[arg(long)]
state: Option<String>,
#[arg(long)]
search: Option<String>,
#[arg(long = "label")]
label: Vec<String>,
#[arg(long)]
limit: Option<u32>,
#[arg(long)]
milestone: Option<String>,
},
View {
number: u64,
},
Precheck {
#[arg(long)]
input: String,
#[arg(long, conflicts_with = "live")]
response: Option<String>,
#[arg(long)]
live: bool,
},
Close {
number: u64,
},
Reopen {
number: u64,
},
Comment {
number: u64,
#[arg(long)]
body: Option<String>,
#[arg(long = "body-file")]
body_file: Option<String>,
},
Comments {
number: u64,
#[arg(long)]
limit: Option<u32>,
},
AddLabel {
number: u64,
#[arg(long = "label", num_args = 1.., required = true)]
label: Vec<String>,
},
RemoveLabel {
number: u64,
#[arg(long)]
label: String,
},
}
#[must_use]
fn should_use_remote_url_for_gitlab(command: &IssueCommand) -> bool {
!matches!(command, IssueCommand::Create { repo: Some(_), .. })
}
#[allow(
clippy::too_many_lines,
reason = "Command dispatch: each match arm maps to one operation"
)]
pub async fn handle(
command: IssueCommand,
platform: &str,
repo: &str,
remote_url: &str,
output_format: OutputFormat,
) -> miette::Result<()> {
if let IssueCommand::Search(args) = &command {
return super::query_search::handle(
gitflow_core::query_filter::Target::Issue,
args.clone(),
platform,
repo,
remote_url,
)
.await;
}
if let IssueCommand::Precheck {
input,
response,
live,
} = &command
{
let report = super::issue_precheck::handle(input.clone(), response.clone(), *live).await?;
let output = CliOutput::success(report, "local", "issue precheck");
return print_output(&output, &output_format);
}
let effective_repo = match &command {
IssueCommand::Create {
repo: Some(override_repo),
..
} => override_repo.as_str(),
_ => repo,
};
let provider: Box<dyn IssueProvider> = match platform {
"github" => Box::new(GitHubIssueProvider::new(effective_repo)),
"gitlab" => {
if should_use_remote_url_for_gitlab(&command) && !remote_url.is_empty() {
Box::new(GitLabIssueProvider::with_remote_url(
effective_repo,
remote_url,
))
} else {
Box::new(GitLabIssueProvider::new(effective_repo))
}
}
"gitcode" => Box::new(GitCodeIssueProvider::new(effective_repo)),
other => {
return Err(miette::miette!(
"Platform '{other}' not yet supported for issue commands"
));
}
};
match command {
IssueCommand::Search(_) => return Err(miette::miette!("invalid search dispatch")),
IssueCommand::Create {
title,
body,
body_file,
label,
assignee,
milestone,
repo: _,
} => {
let resolved_body = resolve_body(body, body_file)?;
let args = CreateIssueArgs {
title,
body: resolved_body,
labels: label,
assignees: assignee,
milestone,
};
let issue = provider
.create(args)
.await
.map_err(|e| miette::miette!("Failed to create issue: {e}"))?;
let output = CliOutput::success(issue, platform, "issue create");
print_output(&output, &output_format)?;
}
IssueCommand::Edit {
number,
title,
body,
body_file,
milestone,
remove_milestone,
} => {
let resolved_body = resolve_body(body, body_file)?;
let resolved_milestone = match (milestone, remove_milestone) {
(Some(_), true) => {
return Err(miette::miette!(
"--milestone 与 --remove-milestone 不能同时指定"
));
}
(Some(m), false) => Some(Some(m)),
(None, true) => Some(None),
(None, false) => None,
};
ensure_edit_has_changes(
title.as_ref(),
resolved_body.as_ref(),
resolved_milestone.as_ref(),
)?;
let args = EditIssueArgs {
title,
body: resolved_body,
milestone: resolved_milestone,
};
let issue = provider
.edit(number, args)
.await
.map_err(|e| miette::miette!("Failed to edit issue #{number}: {e}"))?;
let output = CliOutput::success(issue, platform, "issue edit");
print_output(&output, &output_format)?;
}
IssueCommand::List {
state,
search,
label,
limit,
milestone,
} => {
let parsed_state = state
.as_deref()
.map(|s| match s {
"open" => Ok(State::Open),
"closed" => Ok(State::Closed),
"all" => Ok(State::All),
other => Err(crate::errors::UserInputError::new(format!(
"Invalid state '{other}'. Expected 'open', 'closed', or 'all'."
))),
})
.transpose()?;
let limit = validate_limit(limit)?;
let args = ListIssueArgs {
state: parsed_state,
labels: label,
search,
limit,
milestone,
};
let paged = provider
.list(args)
.await
.map_err(|e| miette::miette!("Failed to list issues: {e}"))?;
let (items, meta) = paged.into_parts();
print_list_output(items, meta, platform, "issue list", &output_format)?;
}
IssueCommand::View { number } => {
let issue = provider
.view(number)
.await
.map_err(|e| miette::miette!("Failed to view issue #{number}: {e}"))?;
let output = CliOutput::success(issue, platform, "issue view");
print_output(&output, &output_format)?;
}
IssueCommand::Precheck { .. } => return Err(miette::miette!("invalid precheck dispatch")),
IssueCommand::Close { number } => {
let issue = provider
.close(number)
.await
.map_err(|e| miette::miette!("Failed to close issue #{number}: {e}"))?;
let output = CliOutput::success(issue, platform, "issue close");
print_output(&output, &output_format)?;
}
IssueCommand::Reopen { number } => {
let issue = provider
.reopen(number)
.await
.map_err(|e| miette::miette!("Failed to reopen issue #{number}: {e}"))?;
let output = CliOutput::success(issue, platform, "issue reopen");
print_output(&output, &output_format)?;
}
IssueCommand::Comment {
number,
body,
body_file,
} => {
let resolved_body = resolve_comment_body(body, body_file)?;
let comment = provider
.comment(number, &resolved_body)
.await
.map_err(|e| miette::miette!("Failed to comment on issue #{number}: {e}"))?;
let output = CliOutput::success(comment, platform, "issue comment");
print_output(&output, &output_format)?;
}
IssueCommand::Comments { number, limit } => {
let limit = validate_limit(limit)?;
let paged = provider
.list_comments(number, limit)
.await
.map_err(|e| miette::miette!("Failed to list comments for issue #{number}: {e}"))?;
let (items, meta) = paged.into_parts();
print_list_output(items, meta, platform, "issue comments", &output_format)?;
}
IssueCommand::AddLabel { number, label } => {
provider
.add_labels(number, &label)
.await
.map_err(|e| miette::miette!("Failed to add labels to issue #{number}: {e}"))?;
let result = serde_json::json!({
"number": number,
"labels_added": label,
});
let output = CliOutput::success(result, platform, "issue add-label");
print_output(&output, &output_format)?;
}
IssueCommand::RemoveLabel { number, label } => {
provider
.remove_label(number, &label)
.await
.map_err(|e| miette::miette!("Failed to remove label from issue #{number}: {e}"))?;
let result = serde_json::json!({
"number": number,
"label_removed": label,
});
let output = CliOutput::success(result, platform, "issue remove-label");
print_output(&output, &output_format)?;
}
}
Ok(())
}
#[allow(
clippy::disallowed_methods,
reason = "Sync file read; called from async handler but file body input is small and local"
)]
fn resolve_body(body: Option<String>, body_file: Option<String>) -> miette::Result<Option<String>> {
if body.is_some() && body_file.is_some() {
return Err(miette::miette!(
"Cannot specify both --body and --body-file"
));
}
if let Some(path) = body_file {
let safe = gitflow_core::SafePath::new_allow_absolute(&path)
.map_err(|e| miette::miette!("无效的 --body-file 参数: {e}"))?;
let content = std::fs::read_to_string(safe.as_path())
.map_err(|e| miette::miette!("Failed to read body file '{path}': {e}"))?;
return Ok(Some(content));
}
Ok(body)
}
fn resolve_comment_body(body: Option<String>, body_file: Option<String>) -> miette::Result<String> {
let resolved = resolve_body(body, body_file)?;
resolved.ok_or_else(|| miette::miette!("Comment body is required. Use --body or --body-file."))
}
fn ensure_edit_has_changes(
title: Option<&String>,
body: Option<&String>,
milestone: Option<&Option<String>>,
) -> miette::Result<()> {
if title.is_none() && body.is_none() && milestone.is_none() {
return Err(miette::miette!(
"Nothing to edit. Provide --title, --body/--body-file, --milestone, or \
--remove-milestone."
));
}
Ok(())
}
fn print_output<T: serde::Serialize>(value: &T, format: &OutputFormat) -> miette::Result<()> {
crate::commands::output::print_output(value, format)
}
#[cfg(test)]
#[allow(
clippy::panic,
reason = "Test code: panic is acceptable for assertion failures"
)]
mod tests {
use super::*;
#[test]
fn test_should_resolve_body_with_body_only() {
let result = resolve_body(Some("hello".into()), None);
assert!(result.is_ok());
assert_eq!(result.expect("already checked"), Some("hello".into()));
}
#[test]
fn test_should_resolve_body_with_none() {
let result = resolve_body(None, None);
assert!(result.is_ok());
assert_eq!(result.expect("already checked"), None);
}
#[test]
fn test_should_resolve_body_from_file() {
let file = tempfile::NamedTempFile::new().expect("create temp file");
std::fs::write(file.path(), "file content here").expect("write temp file");
let result = resolve_body(None, Some(file.path().to_string_lossy().into_owned()));
assert!(result.is_ok());
assert_eq!(
result.expect("already checked"),
Some("file content here".into())
);
}
#[test]
fn test_should_error_on_missing_body_file() {
let result = resolve_body(None, Some("/nonexistent/path/body.md".into()));
assert!(result.is_err());
let err = result.unwrap_err().to_string();
assert!(err.contains("Failed to read body file"));
}
#[test]
fn test_should_reject_body_file_with_path_traversal() {
let result = resolve_body(None, Some("../secret.md".into()));
assert!(result.is_err());
let err = result.unwrap_err().to_string();
assert!(err.contains("无效的 --body-file 参数"));
}
#[test]
fn test_should_reject_body_file_with_nul_byte() {
let result = resolve_body(None, Some("foo\0bar.md".into()));
assert!(result.is_err());
let err = result.unwrap_err().to_string();
assert!(err.contains("无效的 --body-file 参数"));
}
#[test]
fn test_should_reject_both_body_and_body_file() {
let result = resolve_body(Some("hello".into()), Some("/tmp/body.md".into()));
assert!(result.is_err());
let err = result.unwrap_err().to_string();
assert!(err.contains("Cannot specify both"));
}
#[test]
fn test_should_error_when_edit_has_no_changes() {
let result = ensure_edit_has_changes(None, None, None);
assert!(result.is_err());
let err = result.unwrap_err().to_string();
assert!(err.contains("Nothing to edit"));
}
#[test]
fn test_should_use_remote_url_when_no_repo_override() {
let command = IssueCommand::View { number: 42 };
assert!(should_use_remote_url_for_gitlab(&command));
}
#[test]
fn test_should_not_use_remote_url_when_create_has_repo_override() {
let command = IssueCommand::Create {
title: "t".into(),
body: None,
body_file: None,
label: vec![],
assignee: vec![],
milestone: None,
repo: Some("other/repo".into()),
};
assert!(!should_use_remote_url_for_gitlab(&command));
}
#[test]
fn test_should_use_remote_url_when_create_has_no_repo_override() {
let command = IssueCommand::Create {
title: "t".into(),
body: None,
body_file: None,
label: vec![],
assignee: vec![],
milestone: None,
repo: None,
};
assert!(should_use_remote_url_for_gitlab(&command));
}
#[test]
fn test_should_allow_edit_with_title_only() {
let title = Some("T".to_string());
let result = ensure_edit_has_changes(title.as_ref(), None, None);
assert!(result.is_ok());
}
#[test]
fn test_should_allow_edit_with_body_only() {
let body = Some("B".to_string());
let result = ensure_edit_has_changes(None, body.as_ref(), None);
assert!(result.is_ok());
}
#[test]
fn test_should_allow_edit_with_both_title_and_body() {
let title = Some("T".to_string());
let body = Some("B".to_string());
let result = ensure_edit_has_changes(title.as_ref(), body.as_ref(), None);
assert!(result.is_ok());
}
#[test]
fn test_should_require_comment_body() {
let result = resolve_comment_body(None, None);
assert!(result.is_err());
let err = result.unwrap_err().to_string();
assert!(err.contains("Comment body is required"));
}
#[test]
fn test_should_resolve_comment_body_with_body() {
let result = resolve_comment_body(Some("a comment".into()), None);
assert!(result.is_ok());
assert_eq!(result.expect("already checked"), "a comment");
}
#[test]
fn test_should_print_json_output() {
let value = serde_json::json!({"number": 1, "title": "test"});
let result = print_output(&value, &OutputFormat::Json);
assert!(result.is_ok());
}
#[test]
fn test_should_accept_text_output() {
let value = serde_json::json!({"number": 1});
let result = print_output(&value, &OutputFormat::Text);
assert!(result.is_ok());
}
#[test]
fn test_should_parse_issue_close() {
use clap::Parser;
let cli = crate::Cli::try_parse_from(["gitflow", "issue", "close", "42"]).expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Close { number }) => {
assert_eq!(number, 42);
}
_ => panic!("Expected IssueCommand::Close"),
}
}
#[test]
fn test_should_parse_issue_reopen() {
use clap::Parser;
let cli = crate::Cli::try_parse_from(["gitflow", "issue", "reopen", "7"]).expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Reopen { number }) => {
assert_eq!(number, 7);
}
_ => panic!("Expected IssueCommand::Reopen"),
}
}
#[test]
fn test_should_parse_issue_comment_with_body() {
use clap::Parser;
let cli =
crate::Cli::try_parse_from(["gitflow", "issue", "comment", "10", "--body", "LGTM"])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Comment {
number,
body,
body_file,
}) => {
assert_eq!(number, 10);
assert_eq!(body, Some("LGTM".into()));
assert!(body_file.is_none());
}
_ => panic!("Expected IssueCommand::Comment"),
}
}
#[test]
fn test_should_parse_issue_add_label() {
use clap::Parser;
let cli = crate::Cli::try_parse_from([
"gitflow",
"issue",
"add-label",
"5",
"--label",
"bug",
"urgent",
])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::AddLabel { number, label }) => {
assert_eq!(number, 5);
assert_eq!(label, vec!["bug".to_string(), "urgent".to_string()]);
}
_ => panic!("Expected IssueCommand::AddLabel"),
}
}
#[test]
fn test_should_parse_issue_remove_label() {
use clap::Parser;
let cli = crate::Cli::try_parse_from([
"gitflow",
"issue",
"remove-label",
"3",
"--label",
"wontfix",
])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::RemoveLabel { number, label }) => {
assert_eq!(number, 3);
assert_eq!(label, "wontfix");
}
_ => panic!("Expected IssueCommand::RemoveLabel"),
}
}
#[test]
fn test_should_parse_issue_create_with_repo() {
use clap::Parser;
let cli = crate::Cli::try_parse_from([
"gitflow",
"issue",
"create",
"--title",
"Bug report",
"--repo",
"owner/repo",
])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Create { title, repo, .. }) => {
assert_eq!(title, "Bug report");
assert_eq!(repo, Some("owner/repo".to_string()));
}
_ => panic!("Expected IssueCommand::Create"),
}
}
#[test]
fn test_should_parse_issue_create_without_repo() {
use clap::Parser;
let cli =
crate::Cli::try_parse_from(["gitflow", "issue", "create", "--title", "Bug report"])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Create { repo, .. }) => {
assert!(repo.is_none());
}
_ => panic!("Expected IssueCommand::Create"),
}
}
#[test]
fn test_should_parse_issue_view() {
use clap::Parser;
let cli = crate::Cli::try_parse_from(["gitflow", "issue", "view", "42"]).expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::View { number }) => {
assert_eq!(number, 42);
}
_ => panic!("Expected IssueCommand::View"),
}
}
#[test]
fn test_should_parse_read_only_issue_precheck() {
use clap::Parser;
let cli = crate::Cli::try_parse_from([
"gitflow",
"issue",
"precheck",
"--input",
"/tmp/issue.json",
"--live",
])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Precheck {
input,
response,
live,
}) => {
assert_eq!(input, "/tmp/issue.json");
assert!(response.is_none());
assert!(live);
}
_ => panic!("Expected IssueCommand::Precheck"),
}
assert!(
crate::Cli::try_parse_from([
"gitflow",
"issue",
"precheck",
"--input",
"/tmp/issue.json",
"--live",
"--response",
"/tmp/answer.json",
])
.is_err()
);
}
#[test]
fn test_should_parse_issue_edit_with_title() {
use clap::Parser;
let cli =
crate::Cli::try_parse_from(["gitflow", "issue", "edit", "42", "--title", "New title"])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Edit {
number,
title,
body,
body_file,
milestone,
remove_milestone,
}) => {
assert_eq!(number, 42);
assert_eq!(title, Some("New title".to_string()));
assert!(body.is_none());
assert!(body_file.is_none());
assert!(milestone.is_none());
assert!(!remove_milestone);
}
_ => panic!("Expected IssueCommand::Edit"),
}
}
#[test]
fn test_should_parse_issue_edit_with_body() {
use clap::Parser;
let cli =
crate::Cli::try_parse_from(["gitflow", "issue", "edit", "42", "--body", "New body"])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Edit { number, body, .. }) => {
assert_eq!(number, 42);
assert_eq!(body, Some("New body".to_string()));
}
_ => panic!("Expected IssueCommand::Edit"),
}
}
#[test]
fn test_should_parse_issue_edit_with_body_file() {
use clap::Parser;
let cli = crate::Cli::try_parse_from([
"gitflow",
"issue",
"edit",
"42",
"--body-file",
"/tmp/body.md",
])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Edit { body_file, .. }) => {
assert_eq!(body_file, Some("/tmp/body.md".to_string()));
}
_ => panic!("Expected IssueCommand::Edit"),
}
}
#[test]
fn test_should_parse_issue_comments() {
use clap::Parser;
let cli =
crate::Cli::try_parse_from(["gitflow", "issue", "comments", "10"]).expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Comments { number, limit }) => {
assert_eq!(number, 10);
assert_eq!(limit, None);
}
_ => panic!("Expected IssueCommand::Comments"),
}
}
#[test]
fn test_should_parse_issue_comments_with_limit() {
use clap::Parser;
let cli =
crate::Cli::try_parse_from(["gitflow", "issue", "comments", "10", "--limit", "5"])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Comments { number, limit }) => {
assert_eq!(number, 10);
assert_eq!(limit, Some(5));
}
_ => panic!("Expected IssueCommand::Comments"),
}
}
#[test]
fn test_should_parse_issue_list_with_state() {
use clap::Parser;
let cli = crate::Cli::try_parse_from([
"gitflow", "issue", "list", "--state", "open", "--label", "bug", "--search", "crash",
"--limit", "10",
])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::List {
state,
search,
label,
limit,
milestone,
}) => {
assert_eq!(state, Some("open".into()));
assert_eq!(search, Some("crash".into()));
assert_eq!(label, vec!["bug".to_string()]);
assert_eq!(limit, Some(10));
assert!(milestone.is_none());
}
_ => panic!("Expected IssueCommand::List"),
}
}
#[test]
fn test_should_parse_issue_create_full() {
use clap::Parser;
let cli = crate::Cli::try_parse_from([
"gitflow",
"issue",
"create",
"--title",
"Full issue",
"--body",
"Description",
"--label",
"bug",
"--label",
"urgent",
"--assignee",
"user1",
"--assignee",
"user2",
])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Create {
title,
body,
label,
assignee,
..
}) => {
assert_eq!(title, "Full issue");
assert_eq!(body, Some("Description".into()));
assert_eq!(label, vec!["bug".to_string(), "urgent".to_string()]);
assert_eq!(assignee, vec!["user1".to_string(), "user2".to_string()]);
}
_ => panic!("Expected IssueCommand::Create"),
}
}
#[test]
fn test_should_parse_issue_create_with_milestone() {
use clap::Parser;
let cli = crate::Cli::try_parse_from([
"gitflow",
"issue",
"create",
"--title",
"With milestone",
"--milestone",
"v1.0",
])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Create { milestone, .. }) => {
assert_eq!(milestone, Some("v1.0".to_string()));
}
_ => panic!("Expected IssueCommand::Create"),
}
}
#[test]
fn test_should_parse_issue_edit_with_milestone() {
use clap::Parser;
let cli =
crate::Cli::try_parse_from(["gitflow", "issue", "edit", "42", "--milestone", "v2.0"])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Edit {
milestone,
remove_milestone,
..
}) => {
assert_eq!(milestone, Some("v2.0".to_string()));
assert!(!remove_milestone);
}
_ => panic!("Expected IssueCommand::Edit"),
}
}
#[test]
fn test_should_parse_issue_edit_with_remove_milestone() {
use clap::Parser;
let cli =
crate::Cli::try_parse_from(["gitflow", "issue", "edit", "42", "--remove-milestone"])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::Edit {
milestone,
remove_milestone,
..
}) => {
assert!(milestone.is_none());
assert!(remove_milestone);
}
_ => panic!("Expected IssueCommand::Edit"),
}
}
#[tokio::test]
async fn test_should_error_when_edit_has_milestone_and_remove_milestone() {
let command = IssueCommand::Edit {
number: 42,
title: None,
body: None,
body_file: None,
milestone: Some("v2.0".to_string()),
remove_milestone: true,
};
let result = handle(command, "github", "owner/repo", "", OutputFormat::Json).await;
assert!(result.is_err());
let err = result.unwrap_err().to_string();
assert!(err.contains("不能同时指定"));
}
#[test]
fn test_should_parse_issue_list_with_milestone() {
use clap::Parser;
let cli = crate::Cli::try_parse_from(["gitflow", "issue", "list", "--milestone", "v1.0"])
.expect("parse");
match cli.command {
crate::Commands::Issue(IssueCommand::List { milestone, .. }) => {
assert_eq!(milestone, Some("v1.0".to_string()));
}
_ => panic!("Expected IssueCommand::List"),
}
}
#[test]
fn test_should_print_toon_output() {
let value = serde_json::json!({"number": 1, "title": "test"});
let result = print_output(&value, &OutputFormat::Toon);
assert!(result.is_ok());
}
#[test]
fn test_should_print_auto_output() {
let value = serde_json::json!({"number": 1, "title": "test"});
let result = print_output(&value, &OutputFormat::Auto);
assert!(result.is_ok());
}
}