-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rm subcommand, remove set subcommand
- Loading branch information
1 parent
62fec96
commit b82f905
Showing
14 changed files
with
161 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
"""Automated tools for managing alacritty configurations""" | ||
|
||
__version__ = "0.3.1" | ||
__version__ = "0.3.2" | ||
|
||
|
||
class PycrittyError(Exception): | ||
"""General error that might be thrown at any point""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from .pycritty import parser, subparsers | ||
from .set import set_parser | ||
from .list import list_parser | ||
from .ls import list_parser | ||
from .save import save_parser | ||
from .load import load_parser | ||
from .install import install_parser | ||
from .rm import remove_parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import argparse | ||
from .pycritty import subparsers, formatter | ||
|
||
|
||
remove_parser = subparsers.add_parser( | ||
'rm', | ||
help='Remove config files (themes or saves)', | ||
formatter_class=formatter(), | ||
argument_default=argparse.SUPPRESS, | ||
) | ||
|
||
remove_parser.add_argument( | ||
'configs', | ||
metavar='name', | ||
nargs='+', | ||
help='Themes or saved configs to be removed', | ||
) | ||
|
||
group = remove_parser.add_mutually_exclusive_group() | ||
|
||
group.add_argument( | ||
'-c', '--config', | ||
action='store_true', | ||
help='Remove saved config (default)', | ||
) | ||
|
||
group.add_argument( | ||
'-t', '--theme', | ||
dest='theme', | ||
action='store_true', | ||
help='Remove theme', | ||
) | ||
|
||
remove_parser.add_argument( | ||
'-f', '--force', | ||
action='store_true', | ||
help="Don't prompt for confirmation", | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
from .set import SetConfig | ||
from .list import ListResource | ||
from .pycritty import SetConfig | ||
from .ls import ListResource | ||
from .save import SaveConfig | ||
from .load import LoadConfig | ||
from .install import Install | ||
from .rm import Remove | ||
|
||
subcommands = { | ||
'set': SetConfig, | ||
'list': ListResource, | ||
'ls': ListResource, | ||
'save': SaveConfig, | ||
'load': LoadConfig, | ||
'install': Install, | ||
'rm': Remove, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Dict, Any, List | ||
from .command import Command | ||
from ..resources import saves_dir, themes_dir | ||
from ..resources.resource import Resource, ConfigFile | ||
from ..io import log | ||
|
||
|
||
class Remove(Command): | ||
def remove(self, configs: List[str], config_parent: Resource, force=False): | ||
for conf in configs: | ||
file = ConfigFile(config_parent.path, conf, ConfigFile.YAML) | ||
if not file.exists(): | ||
log.warn(f'{conf} ->', log.Color.BOLD, file, log.Color.YELLOW, 'not found') | ||
continue | ||
confirmed = force | ||
if not confirmed: | ||
log.color_print(f'Removing {conf} ->', log.Color.BLUE, log.Color.BOLD, file) | ||
confirmed = 'y' in input('Confirm (y/n): ').lower() | ||
if confirmed: | ||
file.path.unlink() | ||
|
||
def execute(self, actions: Dict[str, Any]): | ||
if 'configs' not in actions: | ||
return | ||
force = 'force' in actions | ||
config_parent = themes_dir if 'theme' in actions else saves_dir | ||
self.remove(actions['configs'], config_parent, force) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.