Skip to content

Commit

Permalink
Print help information if run with any arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Wint3rmute committed Aug 26, 2023
1 parent 439fe54 commit a61a897
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tnb"
version = "2.0.3"
version = "2.1.0"
authors = ["wint3rmute <mateusz.baczek1998@gmail.com>"]
edition = "2021"
description = "command | tnb - pipe your commands to your Telegram Notifications Bot"
Expand Down
20 changes: 20 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use serde::{Deserialize, Serialize};
use std::fs;
use std::path::Path;

const VERSION: &str = env!("CARGO_PKG_VERSION");
const REPOSITORY_ADDRESS: &str = env!("CARGO_PKG_REPOSITORY");

enum ConfigFileCreationStatus {
AlreadyExists,
Created,
Expand Down Expand Up @@ -106,6 +109,23 @@ impl Bot {
}

fn main() {
if std::env::args().len() > 1 {
println!("tnb - Telegram Notification Bot, version {VERSION}");
println!();

println!("This program is meant to be run without any arguments/flags and take input from stdin or a pipe.");

let conf_file_path = ConfigurationFile::get_path();
println!("If you're having issues with sending messages, verify your configuration file: {conf_file_path}");
println!();

println!("For more help, refer to project's README.md: {REPOSITORY_ADDRESS}");
println!();
println!("Have a peaceful day!");

std::process::exit(1);
}

match ConfigurationFile::create_new() {
ConfigFileCreationStatus::Created => {}
ConfigFileCreationStatus::AlreadyExists => {
Expand Down

0 comments on commit a61a897

Please sign in to comment.