We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 13e6c33 commit c940f6aCopy full SHA for c940f6a
link_stacklog/database.py
@@ -17,11 +17,14 @@ def user_dir():
17
path.mkdir(exist_ok=True, parents=True)
18
return path
19
20
-def get_database() -> sqlite_utils.Database:
+def get_database(init=False) -> sqlite_utils.Database:
21
+ if not init and not (user_dir() / DATABASE_FILE).exists():
22
+ click.echo("Database not found. Run 'link-stacklog init' first.")
23
+ raise click.Abort()
24
return sqlite_utils.Database(user_dir() / DATABASE_FILE)
25
26
def init_db():
- db = get_database()
27
+ db = get_database(init=True)
28
29
db["links"].create({
30
"id": int,
0 commit comments