Skip to content

Commit ce57b29

Browse files
chore: update workflows, remove text formatting
Signed-off-by: Henry Gressmann <[email protected]>
1 parent c625518 commit ce57b29

File tree

5 files changed

+27
-37
lines changed

5 files changed

+27
-37
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
with:
6969
name: web-dist
7070
path: ./web/dist
71-
- uses: actions-rust-lang/[email protected].0
71+
- uses: actions-rust-lang/[email protected].2
7272
- uses: taiki-e/[email protected]
7373
with:
7474
bin: liwan

.github/workflows/test.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ jobs:
2424
- uses: actions/checkout@v5
2525
with:
2626
persist-credentials: false
27-
- uses: actions-rust-lang/[email protected]
27+
- uses: actions-rust-lang/[email protected]
28+
with:
29+
components: clippy, rustfmt
2830
- uses: Swatinem/[email protected]
2931
- run: mkdir ./web/dist
3032
- name: Run tests

src/app/models.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
use std::fmt::Display;
2+
3+
use chrono::{DateTime, Utc};
4+
use poem_openapi::Enum;
5+
use serde::{Deserialize, Serialize};
6+
17
#[derive(Debug, Clone)]
28
pub struct Event {
39
pub entity_id: String,
@@ -50,6 +56,15 @@ pub enum UserRole {
5056
User,
5157
}
5258

59+
impl Display for UserRole {
60+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
61+
match self {
62+
UserRole::Admin => write!(f, "admin"),
63+
UserRole::User => write!(f, "user"),
64+
}
65+
}
66+
}
67+
5368
impl TryFrom<String> for UserRole {
5469
type Error = String;
5570

@@ -62,16 +77,6 @@ impl TryFrom<String> for UserRole {
6277
}
6378
}
6479

65-
impl UserRole {
66-
#[allow(clippy::inherent_to_string)]
67-
pub fn to_string(self) -> String {
68-
match self {
69-
Self::Admin => "admin".to_string(),
70-
Self::User => "user".to_string(),
71-
}
72-
}
73-
}
74-
7580
#[macro_export]
7681
macro_rules! event_params {
7782
($event:expr) => {
@@ -99,7 +104,4 @@ macro_rules! event_params {
99104
};
100105
}
101106

102-
use chrono::{DateTime, Utc};
103107
pub use event_params;
104-
use poem_openapi::Enum;
105-
use serde::{Deserialize, Serialize};

src/cli.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ pub fn handle_command(mut config: Config, cmd: Command) -> Result<()> {
9898
let app = Liwan::try_new(config)?;
9999
let users = app.users.all()?;
100100
if users.is_empty() {
101-
println!("{}", bold("No users found"));
101+
println!("No users found");
102102
println!("Use `liwan add-user` to create a new user");
103103
return Ok(());
104104
}
105105

106-
println!("{}", bold("Users:"));
106+
println!("Users:");
107107
for user in users {
108-
println!(" - {} ({:?})", underline(&user.username), user.role);
108+
println!(" - {} ({})", user.username, user.role);
109109
}
110110
}
111111
Command::AddUser(add) => {
@@ -139,15 +139,3 @@ pub fn handle_command(mut config: Config, cmd: Command) -> Result<()> {
139139

140140
Ok(())
141141
}
142-
143-
pub fn bold(s: &str) -> String {
144-
format!("\x1b[1m{}\x1b[0m", s)
145-
}
146-
147-
pub fn underline(s: &str) -> String {
148-
format!("\x1b[4m{}\x1b[0m", s)
149-
}
150-
151-
pub fn white(s: &str) -> String {
152-
format!("\x1b[37m{}\x1b[0m", s)
153-
}

src/web/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::sync::Arc;
66

77
use crate::app::Liwan;
88
use crate::app::models::Event;
9-
use crate::cli::{bold, underline, white};
109
use crossbeam_channel::Sender;
1110
use routes::{dashboard_service, event_service};
1211
use webext::{EmbeddedFilesEndpoint, PoemErrExt, catch_error};
@@ -96,14 +95,13 @@ pub async fn start_webserver(app: Arc<Liwan>, events: Sender<Event>) -> Result<(
9695

9796
match app.onboarding.token()? {
9897
Some(onboarding) => {
99-
let get_started = bold(&format!("{}/setup?t={}", app.config.base_url, onboarding));
100-
let command = bold("liwan --help");
101-
tracing::info!("{}", white("It looks like you're running Liwan for the first time!"));
102-
tracing::info!("{}", white(&format!("You can get started by visiting: {get_started}")));
103-
tracing::info!("{}", white(&format!("To see all available commands, run `{command}`")));
98+
let get_started = format!("{}/setup?t={}", app.config.base_url, onboarding);
99+
tracing::info!("It looks like you're running Liwan for the first time!");
100+
tracing::info!("You can get started by visiting: {get_started}");
101+
tracing::info!("To see all available commands, run `liwan --help`");
104102
}
105103
_ => {
106-
tracing::info!("{} {}", white("Liwan is running on "), underline(&app.config.base_url));
104+
tracing::info!("Liwan is running on {}", app.config.base_url);
107105
}
108106
}
109107

0 commit comments

Comments
 (0)