First application Focus-Ami

Hi, this is my first project in rust. It's a tool to help me keep focused by killing all the applications that I use when I get distracted.

It is multithreaded, one thread to kill and another to attend to the user, allowing to edit the configuration, pause, quit, see the remaining time, and add some other time.

The thread that pays attention to the user needs to do this kind of asynchronously, so it spawns a thread that pays attention synchronously, but can be polled. (I am thinking of building on what I have done in this project to create a library that does this kind of thing).

I'm not really a programmer, and most of my experience has been with python and Matlab, both of which feel really different. I have some bad C and C++ code in my repos, but I have never had a code review. All of this is to say that there are effectively no good conscious decisions regarding style or patterns or anything like that.
Any help with that would be greatly appreciated.

It has been autoformated and clipped, which has been one of my favorite things of the language so far.

It lacks automated tests, but I don't actually know how to test a thread that is supposed to run with another, maybe by mocking the behavior of the other thread?, I would love some suggestions here

I have tested it on a Linux system, and have tried to program it without system specific things, but would be really grateful if someone could give feedback from other systems.

GitLab
GitHub
crate

I'm a newbie, so I can't say much, but:
When using threads from std, you are managing real threads. Consider using asynchronous runtime instead, like Tokio. This way, you'll use virtual threads that can run on any number of real CPU threads (even single). Tokio will manage real threads for you.
Instead of parsing arguments yourself, you can try to use Clap crate instead. Also, look at the "Related Projects" section in its README.
Also, try watching this video on proper error reporting in Rust.
Other than that, maybe explore some TUI crates, like tui-rs, instead of drawing things yourself.

1 Like

Thanks a lot

I will look all of that up, it looks like I've redone a lot of things that were already done

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.