Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a --copyright command #21

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions man/hyprwall.1
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Force overwrite of existing config file.
.br
Should be used with \fB-g\fR.

.TP
\fB\-C\fR, \fB\-\-copyright\fR
Display copyright information

.TP
\fB\-h\fR, \fB\-\-help\fR
Print help
Expand Down
30 changes: 30 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use shellexpand::tilde;
use std::fs::{self, OpenOptions};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::time::{SystemTime, UNIX_EPOCH};
use tokio::process::Command as TokioCommand;
use tokio::runtime::Runtime;

Expand Down Expand Up @@ -54,6 +55,9 @@ struct Cli {
help = "Force overwrite of existing config file (should be used with -g)"
)]
force: bool,

#[arg(short = 'C', long, help = "Display copyright information")]
copyright: bool,
}

fn main() {
Expand All @@ -72,6 +76,32 @@ fn main() {
return;
}

if cli.copyright {
let current_year = 1970
+ (SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("Time went backwards")
.as_secs()
/ (365 * 24 * 60 * 60));
println!("Copyright (C) {} Nyx, Adam Perkowski", current_year);
println!(
"\nThis program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, version 2 of
the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see
<https://www.gnu.org/licenses/old-licenses/gpl-2.0>."
);
return;
}

if !config_exists() {
generate_config();
}
Expand Down