Skip to content

Commit 0d9f047

Browse files
committed
feat: add missing is_enabled and priority fields to CLI output
Fixes #240 - Add is_enabled and priority columns to Screens and Playlists formatters - Display boolean fields with visual indicators (✅ for true, ❌ for false) - Update test expectations to match new output format - Refactor boolean formatting logic to eliminate code duplication - Apply clippy fixes for improved code quality The v3 API documentation indicates these fields should be returned, but they were missing from the CLI table output. Now users can see the complete object information as specified in the API docs.
1 parent fc7c00a commit 0d9f047

File tree

20 files changed

+83
-86
lines changed

20 files changed

+83
-86
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727
};
2828
fs::write(
2929
dest_path,
30-
format!("pub const API_BASE_URL: &str = \"{}\";", api_server),
30+
format!("pub const API_BASE_URL: &str = \"{api_server}\";"),
3131
)
3232
.unwrap();
3333
println!("cargo:rerun-if-changed=build.rs");

src/api/asset.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ impl Api {
2424
Ok(serde_json::from_value(commands::get(
2525
&self.authentication,
2626
&format!(
27-
"v4/assets?select=signature&app_id=eq.{}&app_revision=eq.{}&type=eq.edge-app-file",
28-
app_id, revision
27+
"v4/assets?select=signature&app_id=eq.{app_id}&app_revision=eq.{revision}&type=eq.edge-app-file"
2928
),
3029
)?)?)
3130
}
@@ -38,8 +37,7 @@ impl Api {
3837
let response = commands::get(
3938
&self.authentication,
4039
&format!(
41-
"v4/assets?select=status,processing_error,title&app_id=eq.{}&app_revision=eq.{}&status=neq.finished",
42-
app_id, revision
40+
"v4/assets?select=status,processing_error,title&app_id=eq.{app_id}&app_revision=eq.{revision}&status=neq.finished"
4341
),
4442
)?;
4543

src/api/edge_app/app.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ impl Api {
5353
pub fn delete_app(&self, app_id: &str) -> Result<(), CommandError> {
5454
commands::delete(
5555
&self.authentication,
56-
&format!("v4/edge-apps?id=eq.{}", app_id),
56+
&format!("v4/edge-apps?id=eq.{app_id}"),
5757
)?;
5858
Ok(())
5959
}
6060

6161
pub fn update_app(&self, app_id: &str, name: &str) -> Result<(), CommandError> {
6262
commands::patch(
6363
&self.authentication,
64-
&format!("v4/edge-apps?select=name&id=eq.{}", app_id),
64+
&format!("v4/edge-apps?select=name&id=eq.{app_id}"),
6565
&json!({ "name": name }),
6666
)?;
6767
Ok(())
@@ -70,14 +70,13 @@ impl Api {
7070
pub fn get_app(&self, app_id: &str) -> Result<EdgeApp, CommandError> {
7171
let response = commands::get(
7272
&self.authentication,
73-
&format!("v4/edge-apps?select=name&id=eq.{}", app_id),
73+
&format!("v4/edge-apps?select=name&id=eq.{app_id}"),
7474
)?;
7575

7676
let apps = serde_json::from_value::<Vec<EdgeApp>>(response)?;
7777
if apps.is_empty() {
7878
Err(CommandError::AppNotFound(format!(
79-
"Edge app with ID '{}' not found.",
80-
app_id
79+
"Edge app with ID '{app_id}' not found."
8180
)))
8281
} else {
8382
Ok(apps[0].clone())

src/api/edge_app/channel.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ impl Api {
1616
let response = commands::patch(
1717
&self.authentication,
1818
&format!(
19-
"v4/edge-apps/channels?select=channel,app_revision&channel=eq.{}&app_id=eq.{}",
20-
channel, app_id
19+
"v4/edge-apps/channels?select=channel,app_revision&channel=eq.{channel}&app_id=eq.{app_id}"
2120
),
2221
&json!(
2322
{

src/api/edge_app/installation.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ impl Api {
2121
let response = commands::get(
2222
&self.authentication,
2323
&format!(
24-
"v4.1/edge-apps/installations?select=name&id=eq.{}",
25-
installation_id
24+
"v4.1/edge-apps/installations?select=name&id=eq.{installation_id}"
2625
),
2726
)?;
2827

@@ -43,8 +42,7 @@ impl Api {
4342
let response = commands::get(
4443
&self.authentication,
4544
&format!(
46-
"v4/edge-apps/installations?select=id,name&app_id=eq.{}",
47-
app_id
45+
"v4/edge-apps/installations?select=id,name&app_id=eq.{app_id}"
4846
),
4947
)?;
5048

@@ -56,7 +54,7 @@ impl Api {
5654
pub fn delete_installation(&self, installation_id: &str) -> Result<(), CommandError> {
5755
commands::delete(
5856
&self.authentication,
59-
&format!("v4.1/edge-apps/installations?id=eq.{}", installation_id),
57+
&format!("v4.1/edge-apps/installations?id=eq.{installation_id}"),
6058
)?;
6159
Ok(())
6260
}
@@ -71,7 +69,7 @@ impl Api {
7169
});
7270
commands::patch(
7371
&self.authentication,
74-
&format!("v4.1/edge-apps/installations?id=eq.{}", installation_id),
72+
&format!("v4.1/edge-apps/installations?id=eq.{installation_id}"),
7573
&payload,
7674
)?;
7775
Ok(())

src/api/edge_app/setting.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ where
173173
match SettingType::from_str(&s.to_lowercase()) {
174174
Ok(setting_type) => Ok(setting_type),
175175
Err(_) => Err(serde::de::Error::custom(format!(
176-
"Setting type should be one of the following:\n{}",
177-
valid_setting_types
176+
"Setting type should be one of the following:\n{valid_setting_types}"
178177
))),
179178
}
180179
}
@@ -212,8 +211,7 @@ impl Api {
212211
Ok(deserialize_settings_from_array(commands::get(
213212
&self.authentication,
214213
&format!(
215-
"v4.1/edge-apps/settings?select=name,type,default_value,optional,title,help_text&app_id=eq.{}&order=name.asc",
216-
app_id,
214+
"v4.1/edge-apps/settings?select=name,type,default_value,optional,title,help_text&app_id=eq.{app_id}&order=name.asc",
217215
),
218216
)?)?)
219217
}
@@ -222,8 +220,7 @@ impl Api {
222220
let response = commands::get(
223221
&self.authentication,
224222
&format!(
225-
"v4.1/edge-apps/settings?select=is_global&app_id=eq.{}&name=eq.{}",
226-
app_id, setting_key,
223+
"v4.1/edge-apps/settings?select=is_global&app_id=eq.{app_id}&name=eq.{setting_key}",
227224
),
228225
)?;
229226

@@ -247,8 +244,7 @@ impl Api {
247244
// TODO: test values are returned properly when there are several installations. Most likely need to feed installation_id to the request.
248245
// installation_id=is.null or installation_id=eq.smth
249246
let app_settings: Vec<HashMap<String, serde_json::Value>> = serde_json::from_value(commands::get(&self.authentication,
250-
&format!("v4.1/edge-apps/settings?select=name,type,default_value,optional,title,help_text,edge_app_setting_values(value)&app_id=eq.{}&order=name.asc",
251-
app_id,
247+
&format!("v4.1/edge-apps/settings?select=name,type,default_value,optional,title,help_text,edge_app_setting_values(value)&app_id=eq.{app_id}&order=name.asc",
252248
))?)?;
253249

254250
Ok(EdgeAppSettings::new(serde_json::to_value(app_settings)?))
@@ -262,8 +258,7 @@ impl Api {
262258
let response = commands::get(
263259
&self.authentication,
264260
&format!(
265-
"v4.1/edge-apps/settings?select=name,type,edge_app_setting_values(value)&app_id=eq.{}&edge_app_setting_values.app_id=eq.{}&name=eq.{}",
266-
app_id, app_id, setting_key
261+
"v4.1/edge-apps/settings?select=name,type,edge_app_setting_values(value)&app_id=eq.{app_id}&edge_app_setting_values.app_id=eq.{app_id}&name=eq.{setting_key}"
267262
),
268263
)?;
269264
let settings = serde_json::from_value::<Vec<SettingValue>>(response)?;
@@ -282,8 +277,7 @@ impl Api {
282277
let response = commands::get(
283278
&self.authentication,
284279
&format!(
285-
"v4.1/edge-apps/settings?select=name,type,edge_app_setting_values(value)&edge_app_setting_values.installation_id=eq.{}&name=eq.{}&app_id=eq.{}",
286-
installation_id, setting_key, app_id
280+
"v4.1/edge-apps/settings?select=name,type,edge_app_setting_values(value)&edge_app_setting_values.installation_id=eq.{installation_id}&name=eq.{setting_key}&app_id=eq.{app_id}"
287281
),
288282
)?;
289283

@@ -388,8 +382,7 @@ impl Api {
388382
commands::patch(
389383
&self.authentication,
390384
&format!(
391-
"v4.1/edge-apps/settings/values?app_id=eq.{}&name=eq.{}&installation_id=is.null",
392-
app_id, setting_key
385+
"v4.1/edge-apps/settings/values?app_id=eq.{app_id}&name=eq.{setting_key}&installation_id=is.null"
393386
),
394387
&json!({
395388
"value": setting_value,
@@ -408,8 +401,7 @@ impl Api {
408401
commands::patch(
409402
&self.authentication,
410403
&format!(
411-
"v4.1/edge-apps/settings/values?installation_id=eq.{}&name=eq.{}",
412-
installation_id, setting_key
404+
"v4.1/edge-apps/settings/values?installation_id=eq.{installation_id}&name=eq.{setting_key}"
413405
),
414406
&json!({
415407
"value": setting_value,

src/api/edge_app/version.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ impl Api {
1414
let get_response = commands::get(
1515
&self.authentication,
1616
&format!(
17-
"v4/edge-apps/versions?select=revision&app_id=eq.{}&revision=eq.{}",
18-
app_id, revision
17+
"v4/edge-apps/versions?select=revision&app_id=eq.{app_id}&revision=eq.{revision}"
1918
),
2019
)?;
2120
let version =
@@ -54,8 +53,7 @@ impl Api {
5453
let response = commands::get(
5554
&self.authentication,
5655
&format!(
57-
"v4/edge-apps/versions?select=file_tree&app_id=eq.{}&revision=eq.{}",
58-
app_id, revision
56+
"v4/edge-apps/versions?select=file_tree&app_id=eq.{app_id}&revision=eq.{revision}"
5957
),
6058
)?;
6159

@@ -75,8 +73,7 @@ impl Api {
7573
commands::patch(
7674
&self.authentication,
7775
&format!(
78-
"v4/edge-apps/versions?app_id=eq.{}&revision=eq.{}",
79-
app_id, revision
76+
"v4/edge-apps/versions?app_id=eq.{app_id}&revision=eq.{revision}"
8077
),
8178
&json!({"published": true}),
8279
)?;

src/api/version.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ impl Api {
3030
let response = commands::get(
3131
&self.authentication,
3232
&format!(
33-
"v4.1/edge-apps/versions?select=user_version,description,icon,author,homepage_url,revision,ready_signal&app_id=eq.{}&order=revision.desc&limit=1",
34-
app_id
33+
"v4.1/edge-apps/versions?select=user_version,description,icon,author,homepage_url,revision,ready_signal&app_id=eq.{app_id}&order=revision.desc&limit=1"
3534
),
3635
)?;
3736

src/authentication.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn verify_and_store_token(
130130

131131
fn verify_token(token: &str, api_url: &str) -> anyhow::Result<(), AuthenticationError> {
132132
// Using uuid of non existing playlist. If we get 404 it means we authenticated successfully.
133-
let url = format!("{}/v3/groups/11CF9Z3GZR0005XXKH00F8V20R/", api_url);
133+
let url = format!("{api_url}/v3/groups/11CF9Z3GZR0005XXKH00F8V20R/");
134134
let secret = format!("Token {token}");
135135
let client = reqwest::blocking::Client::builder().build()?;
136136

src/cli.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ pub fn handle_cli_playlist_command(command: &PlaylistCommands) {
612612
match playlist_file {
613613
Ok(playlist) => {
614614
let pretty_playlist_file = serde_json::to_string_pretty(&playlist).unwrap();
615-
println!("{}", pretty_playlist_file);
615+
println!("{pretty_playlist_file}");
616616
}
617617
Err(e) => {
618618
eprintln!("Error occurred when getting playlist: {e:?}")
@@ -864,8 +864,7 @@ pub fn handle_cli_edge_app_command(command: &EdgeAppCommands) {
864864
} => match edge_app_command.deploy(path.clone(), *delete_missing_settings) {
865865
Ok(revision) => {
866866
println!(
867-
"Edge app successfully deployed. Revision: {revision}.",
868-
revision = revision
867+
"Edge app successfully deployed. Revision: {revision}."
869868
);
870869
}
871870
Err(e) => {
@@ -883,7 +882,7 @@ pub fn handle_cli_edge_app_command(command: &EdgeAppCommands) {
883882
println!("Edge app setting successfully set.");
884883
}
885884
Err(e) => {
886-
eprintln!("Failed to set edge app setting: {}", e);
885+
eprintln!("Failed to set edge app setting: {e}");
887886
std::process::exit(1);
888887
}
889888
}
@@ -1136,7 +1135,7 @@ pub fn handle_cli_edge_app_command(command: &EdgeAppCommands) {
11361135
}
11371136
},
11381137
Err(e) => {
1139-
eprintln!("Failed to delete edge app instance. {:?}", e);
1138+
eprintln!("Failed to delete edge app instance. {e:?}");
11401139
std::process::exit(1);
11411140
}
11421141
};

0 commit comments

Comments
 (0)