mosen / mysides

A command line application for managing OS X Finder sidebar favourites
MIT License
226 stars 29 forks source link

Making the Code Easier to Read and update #31

Open kalip2 opened 5 months ago

kalip2 commented 5 months ago

In your project's README, you mentioned that when you first made this code, you didn't have much experience with Objective C/CoreFoundation. Even though you thought the code might not be great, the app works well and many people use it. I wanted to make the code easier to understand, so I changed the names of some functions and variables.

I fixed a part of the code called find_itemname() because it wasn't being used before. I also removed sidebar_insert() because it didn't do anything. It seems like you were waiting for find_itemname() to work properly before making sidebar_insert() useful. But after six years, no one has asked for it, so I deleted it.

I made the error checking clearer by putting it into two new functions, ValidArguments() and ValidateSideBarList(). This makes it easier to see what the add, remove, and list options are doing. I also made a new function called ClearSideBarItems() to remove everything at once, which means RemoveSideBarItem() now just removes one item with the help of the improved FindItemByName().

I updated the xcodeproj files needed to make the code work with the newest Mac Silicon chips.

It's a bit difficult to read the diffs, so checking out the final version of the code might be simpler: https://github.com/mosen/mysides/blob/ebd838ade305e850962f88f492dc1ac559834940/src/main.m

With these changes, the code should be easier for you or anyone else to read and work with in the future. You did a great job making something that helps so many people with automating their Macs, even after all this time.