@ -21,7 +21,7 @@ def run(args, config_path) -> None:
if args . action == " apply " :
if args . action == " apply " :
t . apply ( args . name , force = args . force )
t . apply ( args . name , force = args . force )
if args . action == " apply-all " :
el if args . action == " apply-all " :
run_apply_all ( t , force = args . force )
run_apply_all ( t , force = args . force )
elif args . action == " restore " :
elif args . action == " restore " :
t . restore ( args . name , force = args . force )
t . restore ( args . name , force = args . force )
@ -34,6 +34,12 @@ def run(args, config_path) -> None:
if args . config_action == " add " :
if args . config_action == " add " :
t . config . add ( args . name , args . path )
t . config . add ( args . name , args . path )
t . config . save ( config_path )
t . config . save ( config_path )
elif args . config_action == " disable " :
t . config . disable ( args . name )
t . config . save ( config_path )
elif args . config_action == " enable " :
t . config . enable ( args . name )
t . config . save ( config_path )
elif args . config_action == " get " :
elif args . config_action == " get " :
print ( t . config . get ( args . name ) )
print ( t . config . get ( args . name ) )
elif args . config_action == " list " :
elif args . config_action == " list " :
@ -43,7 +49,7 @@ def run(args, config_path) -> None:
t . config . remove ( args . name )
t . config . remove ( args . name )
t . config . save ( config_path )
t . config . save ( config_path )
elif args . config_action == " update " :
elif args . config_action == " update " :
t . config . update ( args . name , args . path )
t . config . update ( args . name , args . field_key , args . field_value )
t . config . save ( config_path )
t . config . save ( config_path )
@ -51,7 +57,7 @@ def run_apply_all(t: Transpose, force: bool = False) -> None:
"""
"""
Loop over the entries and recreate the symlinks to the store location
Loop over the entries and recreate the symlinks to the store location
Useful after restoring the machine
Useful after restoring a machine
Args :
Args :
t : An instance of Transpose
t : An instance of Transpose
@ -60,19 +66,12 @@ def run_apply_all(t: Transpose, force: bool = False) -> None:
Returns :
Returns :
None
None
"""
"""
results = { }
for entry_name in t . config . entries :
for entry_name in sorted ( t . config . entries ) :
try :
try :
t . apply ( entry_name , force )
t . apply ( entry_name , force )
results [ entry_name ] = { " status " : " success " , " error " : " " }
print ( f " \t {entry_name:<30}: success " )
except TransposeError as e :
except TransposeError as e :
results [ entry_name ] = { " status " : " failure " , " error " : str ( e ) }
for name in sorted ( results ) :
if results [ name ] [ " status " ] != " success " :
print ( f " \t {name:<30}: {results[name][ ' error ' ]} " )
else :
print ( f " \t {name:<30}: success " )
print ( f " \t {entry_name:<30}: {e} " )
def parse_arguments ( args = None ) :
def parse_arguments ( args = None ) :
@ -122,7 +121,7 @@ def parse_arguments(args=None):
apply_all_parser . add_argument (
apply_all_parser . add_argument (
" --force " ,
" --force " ,
dest = " force " ,
dest = " force " ,
help = " If original path already exists, existing path to <path>.backup and continue " ,
help = " Continue with apply even if original path already exists or entry is disabled in config " ,
action = " store_true " ,
action = " store_true " ,
)
)
@ -135,7 +134,12 @@ def parse_arguments(args=None):
" name " ,
" name " ,
help = " The name of the stored entity to restore " ,
help = " The name of the stored entity to restore " ,
)
)
restore_parser . add_argument ( " --force " , dest = " force " , action = " store_true " )
restore_parser . add_argument (
" --force " ,
dest = " force " ,
help = " Continue with restore even if original path already exists or entry is disabled in config " ,
action = " store_true " ,
)
store_parser = subparsers . add_parser (
store_parser = subparsers . add_parser (
" store " ,
" store " ,
@ -176,6 +180,26 @@ def parse_arguments(args=None):
help = " The path of the directory that should be symlinked to the store " ,
help = " The path of the directory that should be symlinked to the store " ,
)
)
config_disable_parser = config_subparsers . add_parser (
" disable " ,
help = " Disable an entry within the config " ,
parents = [ base_parser ] ,
)
config_disable_parser . add_argument (
" name " ,
help = " The name of the entry the config " ,
)
config_enable_parser = config_subparsers . add_parser (
" enable " ,
help = " enable an entry within the config " ,
parents = [ base_parser ] ,
)
config_enable_parser . add_argument (
" name " ,
help = " The name of the entry the config " ,
)
config_get_parser = config_subparsers . add_parser (
config_get_parser = config_subparsers . add_parser (
" get " ,
" get " ,
help = " Retrieve the settings of a specific entity, such as the path " ,
help = " Retrieve the settings of a specific entity, such as the path " ,
@ -212,8 +236,12 @@ def parse_arguments(args=None):
help = " The name of the entry in the store path " ,
help = " The name of the entry in the store path " ,
)
)
config_update_parser . add_argument (
config_update_parser . add_argument (
" path " ,
help = " The path of the directory that should be symlinked to the store " ,
" field_key " ,
help = " The config key to be updated " ,
)
config_update_parser . add_argument (
" field_value " ,
help = " The value to updated in the config " ,
)
)
return parser . parse_args ( args )
return parser . parse_args ( args )