Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixr-codes committed Mar 11, 2023
0 parents commit 59ca5fc
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
111 changes: 111 additions & 0 deletions Cargo.lock

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

14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "penv"
version = "0.1.0"
authors = ["Jonas da Silva"]
description = "Pretty Print Environment Variables"
edition = "2021"
repository = "https://github.com/phoenixr-codes/penv/"
license = "MIT OR Unlicense"
keywords = ["command-line", "env", "environment", "pretty"]
categories = ["command-line-utilities", "visualization"]

[dependencies]
console = "0.15"
glob = "0.3"
21 changes: 21 additions & 0 deletions LICENSE.MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MI License

Copyright (c) 2023 Jonas da Silva

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
25 changes: 25 additions & 0 deletions LICENSE.Unlicense
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Thi is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>
s
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# penv: Pretty Print Environment Variables

## Installation

```text
cargo install penv
```


## Usage

```text
penv [pattern]
```

The `pattern` argument may be a [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) used
to only print variables that match the provided pattern.


## Links

* [📦 crates.io](https://crates.io/crates/penv)
* [📄 GitHub](https://github.com/phoenixr-codes/penv/)


## License

This work is dual-licensed under Unlicense and MIT.
You can choose between one of them if you use this work.

`SPDX-License-Identifier: Unlicense OR MIT`

29 changes: 29 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::env;

use console::style;
use glob::Pattern;

fn main() {
let mut args = env::args();
let filter = args.nth(1);
if args.count() > 0 {
panic!("too many arguments");
}

for (key, value) in env::vars() {
if let Some(ref f) = filter {
if !Pattern::new(f).expect("invalid glob pattern").matches(&key) {
continue;
}
}
println!(
"{}\n{}\n",
style(key).yellow().bold(),
if value.is_empty() {
style("(none)").red().italic().to_string()
} else {
style(value).to_string()
}
);
}
}

0 comments on commit 59ca5fc

Please sign in to comment.