~fd/beetboard

7d8274de9d970e37ddcf1f9565750a16467e9542 — Ersei Saggi 7 months ago a284dac
Improve UX
2 files changed, 44 insertions(+), 12 deletions(-)

M src/lib.rs
M src/strings.rs
M src/lib.rs => src/lib.rs +35 -9
@@ 2,7 2,7 @@ mod entities;
mod split_unquoted_char;
mod strings;

use time::{OffsetDateTime, PrimitiveDateTime};
use time::{format_description, OffsetDateTime, PrimitiveDateTime};

use entities::{prelude::*, *};



@@ 80,7 80,8 @@ impl BeetClient {
            }
            self.user_id = Some(test_user.as_ref().unwrap().as_ref().unwrap().id);
            self.user = Some(test_user.unwrap().unwrap().username);
            return (strings::LOGIN_SUCCESS.to_owned() + strings::PROMPT).to_string();
            return (strings::LOGIN_SUCCESS.to_owned() + strings::HELP + strings::PROMPT)
                .to_string();
        }
    }



@@ 206,8 207,18 @@ impl BeetClient {
        for p in post_finder.all(&self.conn).await.unwrap() {
            output.push_str(
                &format!(
                    "#{}: {}\nBy {} at {}\n\n",
                    p.0.id, p.0.title, p.1[0].username, p.0.date
                    "#{}: {}\n  By {} at {}\n",
                    p.0.id,
                    p.0.title,
                    p.1[0].username,
                    p.0.date
                        .format(
                            &format_description::parse(
                                "[year]-[month]-[day] [hour]:[minute]:[second]"
                            )
                            .unwrap()
                        )
                        .unwrap()
                )
                .to_owned(),
            );


@@ 248,12 259,17 @@ impl BeetClient {

        output.push_str(
            &format!(
                "#{}: {}\nBy {} at {}\n{}\n",
                "#{}: {}\n  By {} at {}\n{}\n",
                p.0.id,
                p.0.title,
                p.1[0].username,
                p.0.date,
                p.0.body.as_ref().unwrap_or(&"empty".to_owned())
                p.0.date
                    .format(
                        &format_description::parse("[year]-[month]-[day] [hour]:[minute]:[second]")
                            .unwrap()
                    )
                    .unwrap(),
                p.0.body.as_ref().unwrap_or(&"[empty]".to_owned())
            )
            .to_owned(),
        );


@@ 268,8 284,18 @@ impl BeetClient {
        for p in comment_finder {
            output.push_str(
                &format!(
                    "Comment #{}: {}\nBy {} at {}\n\n",
                    p.0.id, p.0.title, p.1[0].username, p.0.date,
                    "  #{}: {}\n    By {} at {}\n\n",
                    p.0.id,
                    p.0.title,
                    p.1[0].username,
                    p.0.date
                        .format(
                            &format_description::parse(
                                "[year]-[month]-[day] [hour]:[minute]:[second]"
                            )
                            .unwrap()
                        )
                        .unwrap(),
                )
                .to_owned(),
            );

M src/strings.rs => src/strings.rs +9 -3
@@ 1,5 1,4 @@
pub const GREETING: &str = "
 _ _ _     _                      _          _   _       
pub const GREETING: &str = " _ _ _     _                      _          _   _       
| | | |___| |___ ___ _____ ___   | |_ ___   | |_| |_ ___ 
| | | | -_| |  _| . |     | -_|  |  _| . |  |  _|   | -_|
|_____|___|_|___|___|_|_|_|___|  |_| |___|  |_| |_|_|___|


@@ 50,7 49,14 @@ pub const LOGIN_HELP: &str = "Usage: login username password\n";

pub const LOGIN_BAD: &str = "Bad login! Try again\n";

pub const LOGIN_SUCCESS: &str = "Welcome\n";
pub const LOGIN_SUCCESS: &str = " __      __          ___                                        
/\\ \\  __/\\ \\        /\\_ \\                                       
\\ \\ \\/\\ \\ \\ \\     __\\//\\ \\     ___    ___     ___ ___      __   
 \\ \\ \\ \\ \\ \\ \\  /'__`\\\\ \\ \\   /'___\\ / __`\\ /' __` __`\\  /'__`\\ 
  \\ \\ \\_/ \\_\\ \\/\\  __/ \\_\\ \\_/\\ \\__//\\ \\L\\ \\/\\ \\/\\ \\/\\ \\/\\  __/ 
   \\ `\\___x___/\\ \\____\\/\\____\\ \\____\\ \\____/\\ \\_\\ \\_\\ \\_\\ \\____\\
    '\\/__//__/  \\/____/\\/____/\\/____/\\/___/  \\/_/\\/_/\\/_/\\/____/
\n";

pub const EXIT_COMMANDS: [&str; 3] = ["exit", "quit", "q"];