diff options
author | zlg <zlg@zlg.space> | 2018-03-13 13:16:41 -0700 |
---|---|---|
committer | zlg <zlg@zlg.space> | 2018-03-13 13:16:41 -0700 |
commit | acd531782fc521c6af2c38154b05a36306b92093 (patch) | |
tree | 6709edc03f053e83faa81e8971027cafaad7199a | |
parent | Remove settings from helpers.sh (diff) | |
download | vgstash-acd531782fc521c6af2c38154b05a36306b92093.tar.gz vgstash-acd531782fc521c6af2c38154b05a36306b92093.tar.bz2 vgstash-acd531782fc521c6af2c38154b05a36306b92093.tar.xz vgstash-acd531782fc521c6af2c38154b05a36306b92093.zip |
Make VGSTASH_DB_LOCATION point to a file
It used to point to a directory, which would then look for .vgstash.db.
This behavior was kind of backwards and I don't remember why I did it
that way. This change gives users more control over where they put their
DB.
Be sure to update your environment variable if you have it set!
-rw-r--r-- | README.mdown | 28 | ||||
-rwxr-xr-x | vgstash | 13 |
2 files changed, 20 insertions, 21 deletions
diff --git a/README.mdown b/README.mdown index f054ac3..d78c9ac 100644 --- a/README.mdown +++ b/README.mdown @@ -11,13 +11,13 @@ Nothing fancy like box art or finding games in a massive dropdown box. There are easy flags to track common searches, like "All games that are owned and haven't been beaten", making vgstash convenient. -Since vgstash itself is just a front-end to an SQLite database, other -interfaces to this basic database format can be built to extend the basic -concept. SQLite is supported across tons of languages and platforms, so it's -rather trivial to build another frontend to it. If that's not enough, vgstash -also supports exporting collections as YAML or pipe-delimited lines, and -importing from YAML. This makes batch-editing by a human easy with YAML, and the -raw format is great for pushing vgstash's output through pipes, as any good +Since vgstash itself is just a front-end to an SQLite database, other interfaces +to this database format can be built to extend the basic concept. SQLite is +supported across tons of languages and platforms, so it's rather trivial to +build another frontend to it. If that's not enough, vgstash also supports +exporting collections as YAML or pipe-delimited lines, and importing from YAML. +This makes batch-editing by a human easy with YAML, and the raw format is great +for pushing vgstash's output through pipes, as any good \*nix tool should. ## Data Format @@ -192,10 +192,10 @@ what you're looking for. ## Deleting For one reason or another, you may need to remove items from your game database. -The `delete` command, coupled with the game's ID, will take care of that for -you. If you want to remove *every* game from your collection, delete the -`.vgstash.db` file from your $HOME directory (or whatever `VGSTASH_DB_LOCATION` -is set to) and start over with `vgstash init`. +The `delete` command, coupled with the game's ID, will take care of that +for you. If you want to remove *every* game from your collection, delete +`$HOME/.vgstash.db` (or wherever `VGSTASH_DB_LOCATION` is set to) and start over +with `vgstash init`. # Environment Variables @@ -203,7 +203,7 @@ Customization is pretty important if you're going to manage hundreds of games. There are only a few, but they may come in handy for you! * `VGSTASH_DB_LOCATION` - Defaults to `$HOME`. A file named `.vgstash.db` will be found there. + Defaults to `$HOME/.vgstash.db`. * `VGSTASH_DEFAULT_OWNERSHIP` Can be 0 or 1. Default is 1 (yes). @@ -255,7 +255,7 @@ Here are the current goals: # Copyright -vgstash is Copyright © 2016 Ze Libertine Gamer. It is licensed under the GNU -General Public License, version 3.0. A copy of this license may be found in the +vgstash is Copyright © 2016-2018 zlg. It is licensed under the GNU General +Public License, version 3.0. A copy of this license may be found in the `COPYING` file within this project. It may also be found on the World Wide Web at http://gnu.org/licenses/gpl-3.0.html. @@ -29,17 +29,16 @@ def set_env(): # This makes outside-scope referencing and assignment possible global DB_LOCATION, OWNERSHIP, PROGRESS, TABLE_WIDTH - # Precedence = $VGSTASH_DB_LOCATION, $HOME, or current directory - DB_LOCATION = os.getenv('VGSTASH_DB_LOCATION', os.getenv('HOME', os.getcwd())) + # Precedence = $VGSTASH_DB_LOCATION, $HOME/.vgstash.db + DB_LOCATION = os.getenv('VGSTASH_DB_LOCATION', os.path.join(os.getenv('HOME'), '.vgstash.db')) + print(DB_LOCATION) try: - assert(os.path.isdir(DB_LOCATION)) + assert(os.path.isfile(DB_LOCATION) and os.path.exists(DB_LOCATION)) except AssertionError: - print("VGSTASH_DB_LOCATION is not a valid directory. Unset it to fall back to $HOME, or correct the environment variable.") + print("VGSTASH_DB_LOCATION is not a file. Unset it to fall back to $HOME/.vgstash.db, or correct the environment variable.") sys.exit() - DB_LOCATION = os.path.join(DB_LOCATION, ".vgstash.db") - OWNERSHIP = int(os.getenv('VGSTASH_DEFAULT_OWNERSHIP', OWNERSHIP)) try: assert(OWNERSHIP == 0 or OWNERSHIP == 1) @@ -74,7 +73,7 @@ def init_db(args): print("The database could not be created and/or connected to.") sys.exit() except AssertionError: - print("The database already exists! Delete '%s' and init the database again." % loc) + print("The database already exists! Delete '%s' and init the database again." % DB_LOCATION) sys.exit() # Now let's run a bunch of queries! Fun... |