├── .gitignore ├── .travis.yml ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── bin ├── cli.rs └── usage.txt ├── main.rs ├── scripts ├── build ├── install ├── start └── test └── test └── hello.md /.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | target/ 3 | tmp/ 4 | 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | script: ./scripts/test 3 | rust: 4 | - stable 5 | - beta 6 | - nightly 7 | matrix: 8 | allow_failures: 9 | - rust: nightly 10 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | [root] 2 | name = "how" 3 | version = "1.0.0" 4 | dependencies = [ 5 | "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", 6 | "pulldown-cmark 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 7 | ] 8 | 9 | [[package]] 10 | name = "bitflags" 11 | version = "0.3.3" 12 | source = "registry+https://github.com/rust-lang/crates.io-index" 13 | 14 | [[package]] 15 | name = "getopts" 16 | version = "0.2.14" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | 19 | [[package]] 20 | name = "pulldown-cmark" 21 | version = "0.0.5" 22 | source = "registry+https://github.com/rust-lang/crates.io-index" 23 | dependencies = [ 24 | "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 25 | "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", 26 | ] 27 | 28 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "how" 3 | version = "1.0.0" 4 | description = "How(1) - how to do anything" 5 | keywords = ["how","anything","cli","help","unix","linux","platform","tutorial"] 6 | 7 | [lib] 8 | name = "how" 9 | path = "main.rs" 10 | 11 | [[bin]] 12 | name = "how" 13 | path = "bin/cli.rs" 14 | 15 | [dependencies] 16 | getopts="0.2.14" 17 | pulldown-cmark = "0.0.5" 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) yoshuawuyts 2 | 3 | Permission is hereby granted, free of charge, to any person ob- 4 | taining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without restric- 6 | tion, including without limitation the rights to use, copy, modi- 7 | fy, merge, publish, distribute, sublicense, and/or sell copies of 8 | the Software, and to permit persons to whom the Software is fur- 9 | nished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 16 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONIN- 17 | FRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # how [![stability][0]][1] 2 | [![build status][4]][5] [![test coverage][6]][7] 3 | 4 | `how(1)` - learn how to do anything. [Unix is not discoverable][8], so we need 5 | to fix that. 6 | ```txt 7 | Last login: Wed Nov 4 19:05:55 on ttys000 8 | Type 'how start' to get started. 9 | ❯ 10 | ``` 11 | 12 | ## Installation 13 | ```sh 14 | $ git clone https://github.com/yoshuawuyts/how 15 | ``` 16 | 17 | ## Usage 18 | ```txt 19 | how(1) - learn how to do anything 20 | 21 | Usage: how [options] 22 | 23 | Options: 24 | -h, --help Output usage information 25 | -v, --version Output version number 26 | 27 | Examples: 28 | $ how start # learn how to get started 29 | $ how unix # get an explanation of how unix works 30 | $ how programming # learn how to program 31 | 32 | Docs: https://github.com/yoshuawuyts/how 33 | Bugs: https://github.com/yoshuawuyts/how/issues 34 | ``` 35 | 36 | ## License 37 | [MIT](https://tldrlegal.com/license/mit-license) 38 | 39 | [0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square 40 | [1]: https://nodejs.org/api/documentation.html#documentation_stability_index 41 | [4]: https://img.shields.io/travis/yoshuawuyts/how/master.svg?style=flat-square 42 | [5]: https://travis-ci.org/yoshuawuyts/how 43 | [6]: https://img.shields.io/codecov/c/github/yoshuawuyts/how/master.svg?style=flat-square 44 | [7]: https://codecov.io/github/yoshuawuyts/how 45 | [8]: https://medium.com/@yoshuawuyts/unix-is-not-discoverable-8b64c02a33ef 46 | -------------------------------------------------------------------------------- /bin/cli.rs: -------------------------------------------------------------------------------- 1 | extern crate how; 2 | 3 | use std::process::exit; 4 | use how::how; 5 | use std::env; 6 | 7 | // how 8 | fn main () { 9 | let args: Vec = env::args().collect(); 10 | 11 | if args.len() <= 1 { 12 | usage(); 13 | exit(1); 14 | } 15 | 16 | let keyword = args[1].to_string(); 17 | println!("{}", keyword); 18 | how(&keyword); 19 | } 20 | 21 | fn usage () { 22 | let file = include_str!("./usage.txt"); 23 | println!("{}", file); 24 | } 25 | -------------------------------------------------------------------------------- /bin/usage.txt: -------------------------------------------------------------------------------- 1 | how - learn how to do anything 2 | 3 | Usage: how [options] 4 | 5 | Options: 6 | -h, --help Output usage information 7 | -v, --version Output version number 8 | 9 | Examples: 10 | $ how start # learn how to get started 11 | $ how unix # get an explanation of how unix works 12 | $ how programming # learn how to program 13 | 14 | Docs: https://github.com/yoshuawuyts/how 15 | Bugs: https://github.com/yoshuawuyts/how/issues 16 | -------------------------------------------------------------------------------- /main.rs: -------------------------------------------------------------------------------- 1 | use std::io::BufReader; 2 | use std::fs::File; 3 | use std::io::Read; 4 | 5 | // how 6 | pub fn how (location: &str) { 7 | let f = File::open(location).unwrap(); 8 | let mut rs = BufReader::new(f); 9 | 10 | let mut file = String::new(); 11 | rs.read_to_string(&mut file).unwrap(); 12 | parse_markdown(file) 13 | } 14 | 15 | // parse markdown string 16 | fn parse_markdown (md: String) { 17 | println!("{}", md); 18 | } 19 | -------------------------------------------------------------------------------- /scripts/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cargo build 3 | -------------------------------------------------------------------------------- /scripts/install: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cargo install 3 | -------------------------------------------------------------------------------- /scripts/start: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cargo run "$@" 3 | -------------------------------------------------------------------------------- /scripts/test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cargo test 3 | -------------------------------------------------------------------------------- /test/hello.md: -------------------------------------------------------------------------------- 1 | # hello 2 | world 3 | --------------------------------------------------------------------------------