Skip to content

Commit 3fe3a0f

Browse files
committed
Add --quiet to freeze
1 parent 90f6363 commit 3fe3a0f

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

tmuxp/cli.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,9 @@ def command_shell(
913913
@click.option('-f', '--config-format', type=click.Choice(['yaml', 'json']), help='format to save in')
914914
@click.option('-o', '--save-to', type=click.Path(exists=False), help='file to save to')
915915
@click.option('-y', '--yes', type=bool, is_flag=True, default=False, help="Don't prompt for confirmation")
916+
@click.option('-q', '--quiet', type=bool, is_flag=True, default=False, help="Don't prompt for confirmation")
916917
@click.option('--force', 'force', help='overwrite the config file', is_flag=True)
917-
def command_freeze(session_name, socket_name, config_format, save_to, socket_path, yes, force):
918+
def command_freeze(session_name, socket_name, config_format, save_to, socket_path, yes, quiet, force):
918919
"""Snapshot a session into a config.
919920
920921
If SESSION_NAME is provided, snapshot that session. Otherwise, use the
@@ -939,19 +940,21 @@ def command_freeze(session_name, socket_name, config_format, save_to, socket_pat
939940
newconfig = config.inline(sconf)
940941
configparser.import_config(newconfig)
941942

942-
print(
943-
'---------------------------------------------------------------'
944-
'\n'
945-
'Freeze does its best to snapshot live tmux sessions.\n'
946-
)
943+
if not quiet:
944+
print(
945+
'---------------------------------------------------------------'
946+
'\n'
947+
'Freeze does its best to snapshot live tmux sessions.\n'
948+
)
947949
if not (yes or click.confirm(
948950
'The new config *WILL* require adjusting afterwards. Save config?'
949951
)):
950-
print(
951-
'tmuxp has examples in JSON and YAML format at '
952-
'<http://tmuxp.git-pull.com/examples.html>\n'
953-
'View tmuxp docs at <http://tmuxp.git-pull.com/>.'
954-
)
952+
if not quiet:
953+
print(
954+
'tmuxp has examples in JSON and YAML format at '
955+
'<http://tmuxp.git-pull.com/examples.html>\n'
956+
'View tmuxp docs at <http://tmuxp.git-pull.com/>.'
957+
)
955958
sys.exit()
956959

957960
dest = save_to
@@ -996,17 +999,8 @@ def command_freeze(session_name, socket_name, config_format, save_to, socket_pat
996999
buf.write(newconfig)
9971000
buf.close()
9981001

999-
print('Saved to %s.' % dest)
1000-
1001-
if config_format == 'yaml':
1002-
newconfig = configparser.export(
1003-
'yaml', indent=2, default_flow_style=False, safe=True
1004-
)
1005-
elif config_format == 'json':
1006-
newconfig = configparser.export('json', indent=2)
1007-
else:
1008-
sys.exit('Unknown config format.')
1009-
1002+
if not quiet:
1003+
print('Saved to %s.' % dest)
10101004

10111005

10121006
@cli.command(name='load', short_help='Load tmuxp workspaces.')

0 commit comments

Comments
 (0)