gardesk/garcalc / 7f48608

Browse files

Apply formatting cleanup across app entrypoints

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
7f4860831704cb428c12804e973cedad582b7251
Parents
68f2023
Tree
48a5f82

5 changed files

StatusFile+-
M garcalc/src/config.rs 5 2
M garcalc/src/ipc.rs 3 5
M garcalc/src/main.rs 1 1
M garcalcctl/src/main.rs 3 3
M garcas/src/main.rs 4 2
garcalc/src/config.rsmodified
@@ -153,9 +153,12 @@ impl Config {
153
                 let config = Self::from_lua_table(&calc)?;
153
                 let config = Self::from_lua_table(&calc)?;
154
                 Ok(config)
154
                 Ok(config)
155
             } else {
155
             } else {
156
-                Err(mlua::Error::RuntimeError("gar.calculator not found".to_string()))
156
+                Err(mlua::Error::RuntimeError(
157
+                    "gar.calculator not found".to_string(),
158
+                ))
157
             }
159
             }
158
-        }).map_err(|e| anyhow::anyhow!("Lua error: {}", e))
160
+        })
161
+        .map_err(|e| anyhow::anyhow!("Lua error: {}", e))
159
     }
162
     }
160
 
163
 
161
     /// Parse Config from Lua table
164
     /// Parse Config from Lua table
garcalc/src/ipc.rsmodified
@@ -1,11 +1,11 @@
1
 //! IPC server for garcalc daemon
1
 //! IPC server for garcalc daemon
2
 
2
 
3
-use std::sync::atomic::{AtomicBool, Ordering};
4
 use std::sync::Arc;
3
 use std::sync::Arc;
4
+use std::sync::atomic::{AtomicBool, Ordering};
5
 
5
 
6
 use anyhow::Result;
6
 use anyhow::Result;
7
 use garcalc_cas::Evaluator;
7
 use garcalc_cas::Evaluator;
8
-use garcalc_ipc::{socket_path, Command, Mode, Response, ResponseData};
8
+use garcalc_ipc::{Command, Mode, Response, ResponseData, socket_path};
9
 use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
9
 use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
10
 use tokio::net::{UnixListener, UnixStream};
10
 use tokio::net::{UnixListener, UnixStream};
11
 use tokio::signal;
11
 use tokio::signal;
@@ -142,9 +142,7 @@ impl IpcServer {
142
                 }
142
                 }
143
                 Err(e) => Response::err(e.to_string()),
143
                 Err(e) => Response::err(e.to_string()),
144
             },
144
             },
145
-            Command::GetMode => {
145
+            Command::GetMode => Response::ok_with_data(ResponseData::Mode { mode: self.mode }),
146
-                Response::ok_with_data(ResponseData::Mode { mode: self.mode })
147
-            }
148
             Command::SetMode { mode } => {
146
             Command::SetMode { mode } => {
149
                 self.mode = mode;
147
                 self.mode = mode;
150
                 Response::ok()
148
                 Response::ok()
garcalc/src/main.rsmodified
@@ -10,7 +10,7 @@ mod ui;
10
 
10
 
11
 use anyhow::Result;
11
 use anyhow::Result;
12
 use clap::Parser;
12
 use clap::Parser;
13
-use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
13
+use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};
14
 
14
 
15
 #[derive(Parser, Debug)]
15
 #[derive(Parser, Debug)]
16
 #[command(name = "garcalc")]
16
 #[command(name = "garcalc")]
garcalcctl/src/main.rsmodified
@@ -7,7 +7,7 @@ use std::os::unix::net::UnixStream;
7
 
7
 
8
 use anyhow::{Context, Result};
8
 use anyhow::{Context, Result};
9
 use clap::{Parser, Subcommand};
9
 use clap::{Parser, Subcommand};
10
-use garcalc_ipc::{socket_path, Command, Mode, Response};
10
+use garcalc_ipc::{Command, Mode, Response, socket_path};
11
 
11
 
12
 #[derive(Parser)]
12
 #[derive(Parser)]
13
 #[command(name = "garcalcctl")]
13
 #[command(name = "garcalcctl")]
@@ -98,8 +98,8 @@ fn send_command(command: &Command) -> Result<Response> {
98
     let mut response_line = String::new();
98
     let mut response_line = String::new();
99
     reader.read_line(&mut response_line)?;
99
     reader.read_line(&mut response_line)?;
100
 
100
 
101
-    let response: Response = serde_json::from_str(&response_line)
101
+    let response: Response =
102
-        .context("Failed to parse response from garcalc")?;
102
+        serde_json::from_str(&response_line).context("Failed to parse response from garcalc")?;
103
 
103
 
104
     Ok(response)
104
     Ok(response)
105
 }
105
 }
garcas/src/main.rsmodified
@@ -11,7 +11,7 @@ use std::io::{self, BufRead, Write};
11
 
11
 
12
 use anyhow::{Context, Result};
12
 use anyhow::{Context, Result};
13
 use clap::Parser;
13
 use clap::Parser;
14
-use garcalc_cas::{eval::AngleMode, Evaluator};
14
+use garcalc_cas::{Evaluator, eval::AngleMode};
15
 use tracing_subscriber::EnvFilter;
15
 use tracing_subscriber::EnvFilter;
16
 
16
 
17
 #[derive(Parser)]
17
 #[derive(Parser)]
@@ -38,7 +38,9 @@ struct Args {
38
 
38
 
39
 fn main() -> Result<()> {
39
 fn main() -> Result<()> {
40
     tracing_subscriber::fmt()
40
     tracing_subscriber::fmt()
41
-        .with_env_filter(EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warn")))
41
+        .with_env_filter(
42
+            EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warn")),
43
+        )
42
         .init();
44
         .init();
43
 
45
 
44
     let args = Args::parse();
46
     let args = Args::parse();