formatting
This commit is contained in:
@@ -101,7 +101,9 @@ async fn handle_login(
|
||||
|
||||
// If a URL was provided and the target profile doesn't exist yet, create it.
|
||||
if !config.profiles.contains_key(&target_profile_name) {
|
||||
let url = api_url.clone().unwrap_or_else(|| "http://localhost:8080".to_string());
|
||||
let url = api_url
|
||||
.clone()
|
||||
.unwrap_or_else(|| "http://localhost:8080".to_string());
|
||||
use crate::config::Profile;
|
||||
config.set_profile(
|
||||
target_profile_name.clone(),
|
||||
@@ -155,7 +157,10 @@ async fn handle_login(
|
||||
config.save()?;
|
||||
} else {
|
||||
// Fallback: set_auth writes to the current profile.
|
||||
config.set_auth(response.access_token.clone(), response.refresh_token.clone())?;
|
||||
config.set_auth(
|
||||
response.access_token.clone(),
|
||||
response.refresh_token.clone(),
|
||||
)?;
|
||||
}
|
||||
|
||||
match output_format {
|
||||
|
||||
@@ -79,7 +79,7 @@ pub async fn handle_config_command(
|
||||
}
|
||||
|
||||
async fn handle_list(output_format: OutputFormat) -> Result<()> {
|
||||
let config = CliConfig::load()?; // Config commands always use default profile
|
||||
let config = CliConfig::load()?; // Config commands always use default profile
|
||||
let all_config = config.list_all();
|
||||
|
||||
match output_format {
|
||||
@@ -105,7 +105,7 @@ async fn handle_list(output_format: OutputFormat) -> Result<()> {
|
||||
}
|
||||
|
||||
async fn handle_get(key: String, output_format: OutputFormat) -> Result<()> {
|
||||
let config = CliConfig::load()?; // Config commands always use default profile
|
||||
let config = CliConfig::load()?; // Config commands always use default profile
|
||||
let value = config.get_value(&key)?;
|
||||
|
||||
match output_format {
|
||||
@@ -125,7 +125,7 @@ async fn handle_get(key: String, output_format: OutputFormat) -> Result<()> {
|
||||
}
|
||||
|
||||
async fn handle_profiles(output_format: OutputFormat) -> Result<()> {
|
||||
let config = CliConfig::load()?; // Config commands always use default profile
|
||||
let config = CliConfig::load()?; // Config commands always use default profile
|
||||
let profiles = config.list_profiles();
|
||||
let current = &config.current_profile;
|
||||
|
||||
@@ -170,7 +170,7 @@ async fn handle_profiles(output_format: OutputFormat) -> Result<()> {
|
||||
}
|
||||
|
||||
async fn handle_current(output_format: OutputFormat) -> Result<()> {
|
||||
let config = CliConfig::load()?; // Config commands always use default profile
|
||||
let config = CliConfig::load()?; // Config commands always use default profile
|
||||
|
||||
match output_format {
|
||||
OutputFormat::Json | OutputFormat::Yaml => {
|
||||
@@ -266,7 +266,7 @@ async fn handle_remove_profile(name: String, output_format: OutputFormat) -> Res
|
||||
}
|
||||
|
||||
async fn handle_show_profile(name: String, output_format: OutputFormat) -> Result<()> {
|
||||
let config = CliConfig::load()?; // Config commands always use default profile
|
||||
let config = CliConfig::load()?; // Config commands always use default profile
|
||||
let profile = config
|
||||
.get_profile(&name)
|
||||
.context(format!("Profile '{}' not found", name))?;
|
||||
|
||||
@@ -554,9 +554,7 @@ async fn handle_create(
|
||||
("Label", label.clone()),
|
||||
(
|
||||
"Description",
|
||||
description
|
||||
.clone()
|
||||
.unwrap_or_else(|| "(none)".to_string()),
|
||||
description.clone().unwrap_or_else(|| "(none)".to_string()),
|
||||
),
|
||||
("Version", version.clone()),
|
||||
(
|
||||
@@ -873,8 +871,8 @@ async fn handle_upload(
|
||||
}
|
||||
|
||||
// Read pack ref from pack.yaml so we can display it
|
||||
let pack_yaml_content = std::fs::read_to_string(&pack_yaml_path)
|
||||
.context("Failed to read pack.yaml")?;
|
||||
let pack_yaml_content =
|
||||
std::fs::read_to_string(&pack_yaml_path).context("Failed to read pack.yaml")?;
|
||||
let pack_yaml: serde_yaml_ng::Value =
|
||||
serde_yaml_ng::from_str(&pack_yaml_content).context("Failed to parse pack.yaml")?;
|
||||
let pack_ref = pack_yaml
|
||||
@@ -884,10 +882,7 @@ async fn handle_upload(
|
||||
|
||||
match output_format {
|
||||
OutputFormat::Table => {
|
||||
output::print_info(&format!(
|
||||
"Uploading pack '{}' from: {}",
|
||||
pack_ref, path
|
||||
));
|
||||
output::print_info(&format!("Uploading pack '{}' from: {}", pack_ref, path));
|
||||
output::print_info("Creating archive...");
|
||||
}
|
||||
_ => {}
|
||||
@@ -995,9 +990,7 @@ fn append_dir_to_tar<W: std::io::Write>(
|
||||
append_dir_to_tar(tar, base, &entry_path)?;
|
||||
} else if entry_path.is_file() {
|
||||
tar.append_path_with_name(&entry_path, relative_path)
|
||||
.with_context(|| {
|
||||
format!("Failed to add {} to archive", entry_path.display())
|
||||
})?;
|
||||
.with_context(|| format!("Failed to add {} to archive", entry_path.display()))?;
|
||||
}
|
||||
// symlinks are intentionally skipped
|
||||
}
|
||||
|
||||
@@ -219,10 +219,7 @@ async fn handle_upload(
|
||||
(resolved from workflow_file: '{}' relative to '{}')",
|
||||
workflow_path.display(),
|
||||
workflow_file_rel,
|
||||
action_path
|
||||
.parent()
|
||||
.unwrap_or(Path::new("."))
|
||||
.display()
|
||||
action_path.parent().unwrap_or(Path::new(".")).display()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -230,8 +227,8 @@ async fn handle_upload(
|
||||
let workflow_yaml_content =
|
||||
std::fs::read_to_string(&workflow_path).context("Failed to read workflow YAML file")?;
|
||||
|
||||
let workflow_definition: serde_json::Value =
|
||||
serde_yaml_ng::from_str(&workflow_yaml_content).context(format!(
|
||||
let workflow_definition: serde_json::Value = serde_yaml_ng::from_str(&workflow_yaml_content)
|
||||
.context(format!(
|
||||
"Failed to parse workflow YAML file: {}",
|
||||
workflow_path.display()
|
||||
))?;
|
||||
@@ -411,7 +408,15 @@ async fn handle_list(
|
||||
let mut table = output::create_table();
|
||||
output::add_header(
|
||||
&mut table,
|
||||
vec!["ID", "Reference", "Pack", "Label", "Version", "Enabled", "Tags"],
|
||||
vec![
|
||||
"ID",
|
||||
"Reference",
|
||||
"Pack",
|
||||
"Label",
|
||||
"Version",
|
||||
"Enabled",
|
||||
"Tags",
|
||||
],
|
||||
);
|
||||
|
||||
for wf in &workflows {
|
||||
@@ -512,14 +517,8 @@ async fn handle_show(
|
||||
output::add_header(&mut table, vec!["#", "Name", "Action", "Transitions"]);
|
||||
|
||||
for (i, task) in arr.iter().enumerate() {
|
||||
let name = task
|
||||
.get("name")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("?");
|
||||
let action = task
|
||||
.get("action")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("-");
|
||||
let name = task.get("name").and_then(|v| v.as_str()).unwrap_or("?");
|
||||
let action = task.get("action").and_then(|v| v.as_str()).unwrap_or("-");
|
||||
|
||||
let transition_count = task
|
||||
.get("next")
|
||||
@@ -589,7 +588,8 @@ async fn handle_delete(
|
||||
|
||||
match output_format {
|
||||
OutputFormat::Json | OutputFormat::Yaml => {
|
||||
let msg = serde_json::json!({"message": format!("Workflow '{}' deleted", workflow_ref)});
|
||||
let msg =
|
||||
serde_json::json!({"message": format!("Workflow '{}' deleted", workflow_ref)});
|
||||
output::print_output(&msg, output_format)?;
|
||||
}
|
||||
OutputFormat::Table => {
|
||||
@@ -635,9 +635,7 @@ fn split_action_ref(action_ref: &str) -> Result<(String, String)> {
|
||||
/// YAML is typically at `<pack>/actions/<name>.yaml`, the workflow path is
|
||||
/// resolved relative to the action YAML's parent directory.
|
||||
fn resolve_workflow_path(action_yaml_path: &Path, workflow_file: &str) -> Result<PathBuf> {
|
||||
let action_dir = action_yaml_path
|
||||
.parent()
|
||||
.unwrap_or(Path::new("."));
|
||||
let action_dir = action_yaml_path.parent().unwrap_or(Path::new("."));
|
||||
|
||||
let resolved = action_dir.join(workflow_file);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user