zigup icon indicating copy to clipboard operation
zigup copied to clipboard

ZON Configuration

Open ve-nt opened this issue 11 months ago • 9 comments

I've implemented the ZON configuration file system as discussed in #146.

~A couple of important points before this can be merged:~ ~1) This does not build with Zig 0.13.0, as it relies on std.zon for parsing and serializing the ZON file. If we want to keep zigup pinned to a release instead of master we should wait until 0.14.0 is out, which hopefully wont be too long.~ ~2) A default configuration file path for Windows has not been decided and is currently TODO. I'm not sure what is best here as I don't use Windows much. Once a decision has been made then I'm happy to implement it.~ ~3) Not tested on Windows yet. Once point 2 is done if someone can assist with this that would be perfect, if not I can try it myself.~

ve-nt avatar Feb 08 '25 16:02 ve-nt

Okay! It seems that 0.14.0 has been released, and so we should now start having another look at this PR. The last things to do on this are:

  • Decide where to store the ZON config on Windows. An idea I had was %APPDATA%/zigup/zigup.zon. Thoughts?
  • Test on Windows

I've rebased this back onto the tip of master, and so can start getting this to a mergeable state any time.

ve-nt avatar Mar 14 '25 11:03 ve-nt

%APPDATA%/zigup/zigup.zon would be fine for windows. There's also std.fs.getAppDataDir if you want to use that instead.

marler8997 avatar Mar 15 '25 13:03 marler8997

There's also std.fs.getAppDataDir if you want to use that instead.

This seems like the way to do it. I've added a commit to use this on Windows platforms. I've just done a rudimentary test on Windows. The config file ends up being at path C:\Users\<user>\AppData\Local\zigup\zigup.zon for me, which I think makes sense. zigup is finding the ZON file I placed there and adjusting the install_dir and path_link works as expected.

I've also bumped up the commits here and rebased them onto the tip of master, which included shuffling the XDG_HOME stuff into the Config struct with the rest of the default-path related functions.

All that being said, this should be ready for review now.

ve-nt avatar Mar 17 '25 17:03 ve-nt

Okay, realized there was some overlap between the getHomeDir functions and the XDG home dir stuff. I've taken the liberty to clean up the duplicate code and move the XDG_DATA_HOME code into Config.allocDefaultInstallDir.

ve-nt avatar Mar 17 '25 18:03 ve-nt

With the removal of show-config, I have added an example path_link field setting to the example config in the README, since this will serve as the template for users going forward.

ve-nt avatar Mar 17 '25 18:03 ve-nt

Did a couple tweaks to the PR here but it should be good for review now

ve-nt avatar Mar 19 '25 11:03 ve-nt

Apologies for taking a while to respond. I was thinking about this and going through the readme and had an idea that might make this a bit simpler? I think there's probably only 1, maybe 2 options that zigup users may want to customize via a config file, the "install directory" being the main one. What if instead of a ZON config file that supports setting multiple options, we just have a single optional file for this one option? Also, since there is already an --install-dir option, the user already has a way to specify the installation directory, we're just missing way to tell zigup to retain that option for all future invocations of zigup. So what if we just add a new command-line option to do that? Something like --retain-install-dir? Then user's don't even need to know where this setting is stored, they can just read/write it via the command-line and the actual storage mechanism becomes an implementation detail. We'd also probably want to print this value in zigup's help output moving forward.

This seems like a simpler overall solution to me. We could always enhance this configuration to ZON later though if we add more options? What do you think?

marler8997 avatar Apr 20 '25 14:04 marler8997

FYI, I went ahead and implemented this as a command-line controlled setting for now in this commit: https://github.com/marler8997/zigup/commit/3de4c861a02b2c2b2a10d4274e082db3175e4d3d, i.e.

zigup get-install-dir
zigup set-install-dir PATH

It feels a bit simpler for the user to have to learn/manage I think.

marler8997 avatar Apr 20 '25 19:04 marler8997

That is a whole lot simpler for the end user, I agree. I think the only thing missing is a similar way to set the path link

ve-nt avatar Apr 21 '25 22:04 ve-nt