Giter Club home page Giter Club logo

create_foldable_github_code_block's Introduction

create_foldable_github_code_block

Description

This is a basic Rust program designed to take command results as an argument and generate a string suitable for creating a collapsible code block in GitHub Markdown, which can then be copied to your clipboard.

Usage

$ create_foldable_github_code_block ls -l
$ ls -l | create_foldable_github_code_block

then paste the output into your issue comment or pull request description. For example, the above command will generate the following output:

lsの実行結果(create_foldable_github_code_block, 2024-01-03 02:07:28, 35b2a0b)

実行結果

Cargo.lock
Cargo.toml
README.md
create_foldable_github_code_block-v0.1.0-aarch64-apple-darwin
src
target

git diff(35b2a0bからの差分)

diff --git a/src/lib.rs b/src/lib.rs
index 43b3186..cb0d902 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -39,7 +39,13 @@ pub fn run(command: String, code: String) -> anyhow::Result<()> {
             e
         )
     })?;
-    let relative_path = current_directory.strip_prefix(&root_directory).unwrap();
+
+    // root_directoryより1つ上のディレクトリまでのPathBufを取得
+    let root_directory_parent = root_directory.parent().unwrap();
+
+    let relative_path = current_directory
+        .strip_prefix(root_directory_parent)
+        .unwrap();
 
     let date_now = chrono::Local::now().format("%Y-%m-%d %H:%M:%S").to_string();
 
diff --git a/src/main.rs b/src/main.rs
index 82760d6..ef6483c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -23,7 +23,7 @@ fn main() {
         (stdout, title)
     };
 
-    create_foldable_github_code_block::run(stdout, command).unwrap_or_else(|e| {
+    create_foldable_github_code_block::run(command, stdout).unwrap_or_else(|e| {
         eprintln!("Error: {}", e);
         std::process::exit(1);
     })

Installation

  • By cargo
    • You can install this program by running the following command:
$ cargo install --git https://github.com/Penpen7/create_foldable_github_code_block 
  • By downloading
  • You can install this program by downloading a release, extracting it, and copying the binary to a directory in your PATH.

create_foldable_github_code_block's People

Contributors

penpen7 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.