💾 Archived View for gemini.ctrl-c.club › ~de_alchmst › b-logs › ruby › lstodo:lstodo.gmi captured on 2024-08-25 at 00:50:25. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-26)

➡️ Next capture (2024-08-31)

-=-=-=-=-=-=-

lstodo

github

Lstodo is a simple tool to list your TODO:-like labels. Basically people sometimes write code that contains comments like 'TODO: add this feature' or 'FIXME: this code fails all tests no like seriously, how did it get there?'. I wanted to use them in my team project for school, so I made a small python script to list basic TODOs in entire project. Then I decided that it would be nice to have full cli program to for this, so I made actually good one in ruby.

It will recursively go through given directory and look in all text files that it finds. Then it lists any labels in it with line number and nice formatting. What labels it recognises and how will they be displayed can be configured in json config file. You can also define files/folders to ignore using shell wildcards or regex.

Lstodo supports both *nix platforms (tested on linux) and Windows. Multiple things have been learned while porting to Windows.

1, windows directory structure sucks

Stuff is all over the place. You have %LocalAppData%, but no .config so if you require some configuration file, you have to make folder in %LocalAppData%. This also means you have to add this new folder to %Path%.

2, Window shell variables suck

In normal operating systems variables are just stored in running shell process and are declared in config file. In windows however, they are stored in registry and are set using persistent 'setx' command. This would not be that bad by itself. Hovever it also means that good install script will add its new folder in %LocalAppData% to %Paht% by itself.

This would be fine, but since my install script is also main way to update to (hypotetical) newer version, it needs to check if it is not already added to not add it second time. Also I don't know if there is limit to how long can variable be, but it would be very easy to either add unholy ammount of text to random variables without user noticing or posibly even reach maximum length of %PATH% and make it impossible to add new paths to it.

I will surely experiment with it in diatant future.

3, finding file information on Windows is impossible

On linux, you can use the file command to get file information. Determining whether file is plain text or not is as simple as

`file -b --mime-encoding "#{path}"` =~ /utf-|ascii/

Windows does not have any similar feature, so I need to read some ammount of file and then use

data.force_encoding("UTF-8").valid_encoding?

to see it is text or not.

also try to run it in your node_modules, you will be surprised by how many TODOs and FIXMEs you find in the most basic modules.

----------------------------

previous: guestbook

b-logs

home

ctrl-c.club