Clink is a tool written in Rust to help you keep related code up to date

Hey Rust community,

I wanted to share a project I've been working on for a little while. Clink is a tool I built to address my team's need to keep track of lots of bits of related code that are often written in different languages, or may even have several languages in a single file (Vue has HTML, JS, and CSS in a .vue file, for example). To help us with refactoring and keeping our code clean, I thought it'd be great to have a tool that I can use to mark parts of our code as needing to be watched for changes and likewise mark parts of our code that would be affected by changes to the aforementioned sections of code. Thus, clink was born!

Really simply, clink lets you insert "clink tags" into parts of your code that you want to be reminded about when something else changes. These tags are written with Markdown link syntax (which may need to change), and can fit into any plain text file, such as in your code comments.

// [clink tag](rust_example)
hello();

You can even specify multiple tags between the parentheses by separating them with a comma.

If I now run clink setup -e .git in my git repository, clink will scan every file in my repository except those in my .git directory, and create a .clink file with mappings like:

{
  "tag": "rust_example",
  "anchors": [
     {
      "line_number": 10,
       "file_path": "src/hello_caller.rs"
     }
  ]
}

With a clink tag in place, I can mark a "clink section" so that, when git picks up that a change has been made but not yet staged with git add, I can get a notification about it!

// [clink open](rust_example)
/// Prints a nice message to the user.
fn hello() {
  println!("Hello! Have a fantastic day!");
}
// [clink close]()

Now, if I were to change the contents between the section delimited with [clink open]() and [clink close]() and run clink before staging the changes with git add, I'll get a message like the following:

[+] Some text linking to a file has changed! You should check out
    Line 10: src/hello_caller.rs

If anyone feels so inclined, I'd love to receive feedback about improvements I can make to my code and to the tool!

https://github.com/zsck/clink

3 Likes