-
Notifications
You must be signed in to change notification settings - Fork 7
Add nologin command
#125
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
base: main
Are you sure you want to change the base?
Add nologin command
#125
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| [package] | ||
| name = "uu_nologin" | ||
| version = "0.0.1" | ||
| edition = "2021" | ||
| authors = ["uutils developers"] | ||
| license = "MIT" | ||
| description = "nologin ~ (uutils) Politely refuse a login" | ||
|
|
||
| homepage = "https://github.com/uutils/login" | ||
| repository = "https://github.com/uutils/login/tree/main/src/uu/nologin" | ||
| keywords = ["acl", "uutils", "cross-platform", "cli", "utility"] | ||
| categories = ["command-line-utilities"] | ||
|
|
||
| [dependencies] | ||
| uucore = { workspace = true } | ||
| clap = { workspace = true } | ||
|
|
||
| [lib] | ||
| path = "src/nologin.rs" | ||
|
|
||
| [[bin]] | ||
| name = "nologin" | ||
| path = "src/main.rs" | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # nologin | ||
|
|
||
| ``` | ||
| nologin [options] | ||
| ``` | ||
|
|
||
| politely refuse a login |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| uucore::bin!(uu_nologin); |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,80 @@ | ||||||||||
| // This file is part of the uutils login package. | ||||||||||
| // | ||||||||||
| // For the full copyright and license information, please view the LICENSE | ||||||||||
| // file that was distributed with this source code. | ||||||||||
|
|
||||||||||
| use clap::{crate_version, Arg, Command}; | ||||||||||
| use std::{ffi::OsString, io::Write}; | ||||||||||
| use uucore::{ | ||||||||||
| error::{set_exit_code, UResult}, | ||||||||||
| format_usage, help_about, help_usage, | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| const ABOUT: &str = help_about!("nologin.md"); | ||||||||||
| const USAGE: &str = help_usage!("nologin.md"); | ||||||||||
|
|
||||||||||
| #[uucore::main] | ||||||||||
| pub fn uumain(args: impl uucore::Args) -> UResult<()> { | ||||||||||
| let mut command = uu_app(); | ||||||||||
|
|
||||||||||
| // Mirror GNU options, always return `1`. In particular even the 'successful' cases of no-op, | ||||||||||
| // and the interrupted display of help and version should return `1`. Also, we return Ok in all | ||||||||||
| // paths to avoid the allocation of an error object, an operation that could, in theory, fail | ||||||||||
| // and unwind through the standard library allocation handling machinery. | ||||||||||
| set_exit_code(1); | ||||||||||
|
|
||||||||||
| let args: Vec<OsString> = args.collect(); | ||||||||||
| if args.len() > 2 { | ||||||||||
|
||||||||||
| if args.len() > 2 { | |
| if args.len() > 2 { | |
| writeln!(std::io::stderr(), "Error: too many arguments")?; | |
| writeln!(std::io::stderr(), "Usage: {}", USAGE)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping ? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was an intermediate file I didn't delete and accidentally committed (I think).