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

Help wanted: Implement using ~/.todos.json by default #31

Closed
gammons opened this issue Feb 1, 2017 · 6 comments
Closed

Help wanted: Implement using ~/.todos.json by default #31

gammons opened this issue Feb 1, 2017 · 6 comments

Comments

@gammons
Copy link
Owner

gammons commented Feb 1, 2017

Per the comments of multiple users, I think we should implement this workflow:

  1. when running todolist, see if a .todos.json exists in the current working directory.
  2. If yes, use that .todos.json.
  3. If no, use ~/.todos.json.

Also, add documentation to the gh-pages branch to let users know this is how the app works.

PRs welcome!

@waldyrious
Copy link

For reference, there's been some related code and discussion in #13.

NonerKao added a commit to NonerKao/todolist that referenced this issue Feb 4, 2017
This patch implments the new workflow mentioned in gammons#31, in which
the program still tries to find a repo file in the working directory
first, and it tries the global one in the home directory if no one
is found.

In this patch, the condition check of the existence of the repo file
is done in `todolist/file_store.go` at the very early step before
the input routing.
@NonerKao
Copy link
Collaborator

NonerKao commented Feb 4, 2017

I post a PR first and need your feedback. If it is OK then I'll make the gh-pages part later.

@gammons
Copy link
Owner Author

gammons commented Mar 7, 2017

@NonerKao please update gh-pages when you get a chance.

NonerKao added a commit to NonerKao/todolist that referenced this issue Mar 8, 2017
This patch implements the logic discussed at gammons#31, in which
the program still tries to find a repo file in the working directory
first, and it tries the global one in the home directory if no one
is found.
@NonerKao
Copy link
Collaborator

NonerKao commented Mar 8, 2017

#41 I'm sorry for the serious mistake that should have been taken care of.

I follow your suggestion and do some local test, but it fails many tests. The reason is that, if the location check is made in f.Load(), it will overwrite the f.FileLocation in those tests, which is mostly called todos.json rather than .todos.json, with home repository.

Although the value of f.FileLocation is given when NewFileStore is called, it is not referenced until any a.Load. So I propose commit #42 to fix this without changing all those tests, which containes:

  • in NewFileStore(): set FileLocation default to ""
  • new private function getLocation(): the main logic, those that were in NewFileStore()
  • in Load(): call getLocation() to assign a value to f.FileLocation
  • in Initialize(): check ".todos.json" instead of f.FileLocation

I apologize again for all the inconvenience.

@gammons
Copy link
Owner Author

gammons commented Mar 14, 2017

I'll be getting to this today.

@gammons
Copy link
Owner Author

gammons commented Mar 14, 2017

Merged #42 and I am releasing 0.5.2 now.

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

No branches or pull requests

3 participants