Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement config parsing #22

Merged
merged 18 commits into from
Jan 26, 2024
Merged

Implement config parsing #22

merged 18 commits into from
Jan 26, 2024

Conversation

joebonneau
Copy link
Contributor

@joebonneau joebonneau commented Jan 17, 2024

  • Implements parsing of a sesh/sesh.toml config file and creates a pattern for future use

Open discussion/items:

  • Do we like the pattern of parsing the config file in the main cli command? This prevents us from re-running this logic over and over again within a single call, but does introduce a bit of prop drilling that clutters things up a bit.
  • The scaffolding to implement the "include root dir in session name" feature is there, but is on hold until we determine whether we want to keep that or not

Here's what the config looks like so far (super barebones):

[session.name]
include_root_dir = true

Also, not sure why my commits from the previous PR are showing up here. If there's some better way to be doing this, let me know... I basically just updated my fork from your repo and then added commits to it.

config/config.go Outdated Show resolved Hide resolved
session/determine.go Outdated Show resolved Hide resolved
cmds/choose.go Outdated
@@ -65,7 +66,8 @@ func Choose() *cli.Command {
}
choice := strings.TrimSpace(cmdOutput.String())
// TODO: get choice from Session structs array
connect.Connect(choice, false, "")
config := config.ParseConfigFile()
connect.Connect(choice, false, "", &config)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you like passing all of the config into these functions? I'm not sure how to break up the config file yet but we may end up passing more data than is needed for each function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are two approaches here: pass exactly what we need, or pass a reference to the config.Config struct. That way, we have all the data that is needed (and then some), but we aren't needlessly creating copies of the config struct. I'm open to either, but I will say that it's maybe a little hard to know at this point what we'll need to pass through for future config values and the parameters could get a bit out of hand if they're not all in a single object that you can pass through.

@joshmedeski joshmedeski self-requested a review January 19, 2024 01:23
@joshmedeski
Copy link
Owner

I'm checking with Tom about how he uses this parent dir feature. I'm gonna put this PR on hold until I decide we have something work using for a configuration file.

@joebonneau
Copy link
Contributor Author

I'm checking with Tom about how he uses this parent dir feature. I'm gonna put this PR on hold until I decide we have something work using for a configuration file.

Sounds good. Something that I think it could be used for is specifying startup scripts. I'm thinking it could be set up such that you link a path to a startup script wherever you want to store them, and it'll execute that script after creating the session.

All good either way, happy to work on something else entirely in the meantime!

@joshmedeski
Copy link
Owner

For #7

@joebonneau
Copy link
Contributor Author

joebonneau commented Jan 22, 2024

@joshmedeski I implemented the startup scripts feature and added some docs to go along with it. For now, users can only run persistent scripts, i.e. the created session won't exit when the script exits. I think this is likely what people will want most of the time anyway, but we can implement the opposite behavior down the road if people are interested.

Might need some help with resolving the merge conflicts, though... not entirely sure what the best way of doing that is with go.mod and go.sum.

@joshmedeski
Copy link
Owner

Another merge conflict. But for now can we drop the parent session name? I'd like to address #33 and I'll be adding nerd font support soon, which will be need a config option ;)

@joshmedeski
Copy link
Owner

Sorry for all the merge conflicts, @joebonneau!

I'll review all of this tonight and hopefully we can get it merged very soon.

Copy link
Owner

@joshmedeski joshmedeski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

if err != nil {
return fmt.Errorf("unable to connect to %q: %w", choice, err)
}

if err := zoxide.Add(session.Path); err != nil {
if err = zoxide.Add(session.Path); err != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err = zoxide.Add(session.Path); err != nil {
if err := zoxide.Add(session.Path); err != nil {

We need a : here please

@joshmedeski joshmedeski merged commit b6f0de4 into joshmedeski:main Jan 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants