Skip to content

Commit

Permalink
add --copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
adamperkowski committed Oct 24, 2024
1 parent 820cee6 commit 53bd33e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
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

0 comments on commit 53bd33e

Please sign in to comment.