From fa5e320b41ab1fc6060b485fb58cc2730776d494 Mon Sep 17 00:00:00 2001 From: DTB Date: Tue, 23 Jul 2024 20:14:08 -0600 Subject: [PATCH] argued(1): re-write in Rust --- Makefile | 4 ++-- src/argued.c | 9 --------- src/argued.rs | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 11 deletions(-) delete mode 100644 src/argued.c create mode 100644 src/argued.rs diff --git a/Makefile b/Makefile index d68fbf9..26aadf0 100644 --- a/Makefile +++ b/Makefile @@ -89,8 +89,8 @@ build/include/sysexits.h: build $(SYSEXITS)sysexits.h .PHONY: argued argued: build/bin/argued -build/bin/argued: src/argued.c build - $(CC) $(CFLAGS) -o $@ src/argued.c +build/bin/argued: src/argued.rs build + $(RUSTC) $(RUSTFLAGS) -o $@ src/argued.rs .PHONY: dj dj: build/bin/dj diff --git a/src/argued.c b/src/argued.c deleted file mode 100644 index 80d4266..0000000 --- a/src/argued.c +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2022–2024 DTB - * SPDX-License-Identifier: CC0 - * - * This work is marked with CC0 1.0. To view a copy of this license, visit - * . - */ - -int main(int argc, char *argv[]){ return !(argc > 1); } diff --git a/src/argued.rs b/src/argued.rs new file mode 100644 index 0000000..c6adecc --- /dev/null +++ b/src/argued.rs @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022_2024 DTB + * SPDX-License-Identifier: AGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU Affero General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * 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 Affero General Public License for more + * details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + + use std::{ env::args, process::ExitCode }; + + fn main() -> ExitCode { + let argv = args().collect::>(); + + match argv.len() { + 0 | 1 => ExitCode::FAILURE, + _ => ExitCode::SUCCESS + } + }