Skip to content

Commit

Permalink
chore: cleaning up the files and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvdabhi101 committed Feb 2, 2024
1 parent 0c4479e commit 49022b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
.DS_Store
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn parse_args(args: Args) {
Commands::Deploy(deploy_arg) => deploy(deploy_arg.input, deploy_arg.md),
},
None => {
let items = vec!["Login", "Deploy", "See List"];
let items = vec!["Login", "See List", "Logout", "Exit"];
let selection = Select::with_theme(&dialoguer::theme::ColorfulTheme::default())
.with_prompt("Choose your destiny")
.default(0)
Expand All @@ -35,8 +35,9 @@ pub fn parse_args(args: Args) {
.unwrap();
match selection {
0 => login(),
1 => println!("Deploy"),
2 => println!("See List"),
1 => println!("See List"),
2 => println!("Logout"),
3 => (),
_ => println!("Error"),
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn login() {
}
}

/// deploy the file to the database
pub fn deploy(file: String, md: bool) {
println!("Deploying file: {}", file);
println!("Markdown Support: {}", md);
Expand All @@ -63,6 +64,7 @@ pub fn deploy(file: String, md: bool) {
create_page(title, content, slug, published);
}

/// checks if the token exists
pub fn check_if_token_exists() -> bool {
let home = std::env::var("HOME").unwrap();
let if_file_exists = fs::metadata(format!("{}/.rusty-leaf.toml", home));
Expand All @@ -73,6 +75,7 @@ pub fn check_if_token_exists() -> bool {
}
}

/// gets the token from the file
pub fn get_token() -> String {
if check_if_token_exists() {
let file = fs::read_to_string(format!("{}/.rusty-leaf.toml", std::env::var("HOME").unwrap()));
Expand Down

0 comments on commit 49022b0

Please sign in to comment.