From d327a2883b324bff5fbcd49cd1811daf1f7a99d1 Mon Sep 17 00:00:00 2001 From: Craig Mayhew Date: Mon, 29 Jan 2024 11:59:50 +0000 Subject: [PATCH] Added crate level doc to intro the crate and provide examples --- src/main.rs | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9af3417..130b4ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,30 @@ +//! Pipe your content to gpt directly from the command line. +//! A concept that allows for a lot of possibilities in local environments and CI pipelines +//! +//! ```sh +//! tail -30 /var/httpd.log | pipe-gpt --p "Is there anything in the http log file I should fix?" +//! ``` +//! +//! ```sh +//! cat main.rs | pipegpt -p "How would you improve this code? Include line numbers in your comments so I can tell where you mean." +//! ``` +//! +//!```sh +//!cat main.rs | pipegpt -p "Is this code production ready? If yes reply "Yes". If no, then explain why not. Be concise." +//!``` +//! +//! ```sh +//! cat file.json | pipegpt -p "Convert this JSON to YAML" > file.yaml +//! ``` +//! +//! ```sh +//! cat french.txt | pipegpt -p "Translate this to English please." +//! ``` +//! +//! ```sh +//! git diff -- staged | pipegpt -p "Code review this code change" +//! ``` + // atty to determine if data is piped in or not use atty::Stream; // clap for command line argument parsing @@ -178,24 +205,7 @@ fn args_read (args_setup: Command) -> (std::string::String, i32, f32, f32, bool) /// /// ## Example Usage /// -/// ```bash -/// tail -30 /var/httpd.log | pipe-gpt --p "Is there anything in the http log file I should fix?" -/// ``` -/// ```bash -/// cat main.rs | pipegpt -p "How would you improve this code? Include line numbers in your comments so I can tell where you mean." -/// ``` -/// ```bash -/// cat main.rs | pipegpt -p "Is this code production ready? If yes reply "Yes". If no, then explain why not. Be concise." -/// ``` -/// ```bash -/// cat file.json | pipegpt -p "Convert this JSON to YAML" -/// ``` -/// ```bash -/// cat french.txt | pipegpt -p "Translate this to English please." -/// ``` -/// ```bash -/// git diff -- staged | pipegpt -p "Code review this code change" -/// ``` +/// Please see [crate] level docs for usage examples #[tokio::main] async fn main() { // enable logging