Skip to content

Commit 6402d60

Browse files
committed
Ensure cmus configuration integrity
Create the 'rc' file if it doesn't exist yet, and exit if the 'autosave' file does not exist.
1 parent 4b6574a commit 6402d60

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

cmus_osx/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from click import echo
1515
from click import style
1616

17+
from .constants import AUTOSAVE_MISSING
1718
from .constants import CMUS_OSX_FOLDER_NAME
1819
from .constants import CONFIG_NAME
1920
from .constants import COULD_NOT_LOCATED_CMUS_DIRECTORY
@@ -67,6 +68,16 @@ def entrypoint(ctx):
6768
with open(config_path, "w") as f:
6869
f.write(template(ENV_VAR_PREFIX, ENV))
6970

71+
if not cmus_config.rc_path.is_file():
72+
cmus_config.rc_path.touch()
73+
74+
if not cmus_config.autosave_path.is_file():
75+
echo(
76+
f"{style('ERROR', fg='red')}: cmus config file missing (launch cmus at least once "
77+
"before attempting installation)"
78+
)
79+
exit(AUTOSAVE_MISSING)
80+
7081
locals_ = locals()
7182

7283
for local in (local for local in locals_ if local != "ctx"):

cmus_osx/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
}
3535

3636
COULD_NOT_LOCATED_CMUS_DIRECTORY = 1
37+
AUTOSAVE_MISSING = 2
3738

3839
ENV_VAR_PREFIX = "CMUS_OSX"
3940
ENV: Dict[str, Default] = {

0 commit comments

Comments
 (0)