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

Enhance life add command #64

Open
SanchayanMaity opened this issue Dec 23, 2019 · 5 comments
Open

Enhance life add command #64

SanchayanMaity opened this issue Dec 23, 2019 · 5 comments
Labels

Comments

@SanchayanMaity
Copy link
Contributor

Currently the "life add" command aborts if a life file is not present and the user is starting fresh but wants to add a dotfiles repository. The "onlyRepo" case in lifeAdd function should be enhanced to handle this.

@vrom911 @chshersh Thoughts on this? Would this be an acceptable addition?

@chshersh
Copy link
Contributor

@SanchayanMaity Could you, please clarify a few more details regarding your use case? How could it be that .life file is not present if you created dotfiles with life init command? life add command assumes that you have properly configured .life.

@SanchayanMaity
Copy link
Contributor Author

life init aborts in case the dotfile repository already exists which is the case where whatIsLife returns OnlyRepo. In my use case, one would like to use an existing dotfile repo and have it managed with life-sync. So, the two options would be to modify the OnlyRepo case of lifeInit or lifeAdd. lifeAdd seemed like the one which should be modified.

@chshersh
Copy link
Contributor

I think that supporting use-case with the existing dotfiles repo is worth pursuing. I can propose the following solution:

  1. In OnlyRepo case ask interactively what users want to do: create empty .life file or completely initialize repo from the files (for now the code can simply create empty .life which can be populated with life add later) but in long-term it would be cool to implement full-featured initiliation with checking each file for equality.
  2. In life add if .life file is not present, print a message saying that probably life init can help.

Anyway, creating empty .life file is just touch ~/dotfiles/.life. An it looks like improving the verbosity and usefulness of logging messages can be a worthy goal. Not only tell what went wrong, but also tell, how to fix it.

@SanchayanMaity
Copy link
Contributor Author

From what I understood, .life has to be present in HOME directory only? I did try doing touch .life in HOME directory but in that case it seems TOML parsing fails when calling life add -d dotfiles?

life: Couldnt parse file .life: "Key files not found"

@chshersh
Copy link
Contributor

chshersh commented Dec 24, 2019

@SanchayanMaity Hmm, let me think carefully about invariants we want to preserve and how to handle them properly. I don't have an answer at the moment on the best approach here.

Regarding parsing error: looks like that at the moment the minimal valid file is:

files = []
directories = []

After migrating to the latest tomland version and patching codec, it should be possible to handle empty file as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants