Skip to content

Commit 7253246

Browse files
committed
Add support for multiple YAML files
You can now do: `sshush -s ~/.ssh/config.d/*.yml` And it will process every .yml file it finds.
1 parent 1dda700 commit 7253246

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

sshush/command_line.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ def main():
1212
arg_parser.add_argument(
1313
'--source', '-s',
1414
help='Path to source YAML file if it differs from {}'.format(default_yaml_path),
15-
default=default_yaml_path
15+
default=default_yaml_path,
16+
nargs='+'
1617
)
1718

1819
arg_parser.add_argument(
@@ -28,14 +29,19 @@ def main():
2829
yaml=args.source
2930
))
3031

31-
yaml_obj = read_file(args.source)
32-
config_file_contents = process_yaml(yaml_obj)
33-
3432
try:
3533
with open(args.path, 'w') as fh:
36-
fh.write(config_file_contents)
37-
fh.write("\n")
34+
fh.write('# Generated by sshush')
35+
36+
for file in args.source:
37+
yaml_obj = read_file(file)
38+
config_file_contents = process_yaml(yaml_obj)
39+
40+
fh.write(config_file_contents)
41+
fh.write("\n")
42+
3843
print('{} written successfully'.format(args.path))
44+
3945
except IOError as exc:
4046
print('Error:', exc.strerror)
4147
exit(1)

sshush/sshush.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def read_file(file):
2828

2929

3030
def process_yaml(ssh_config_yaml):
31-
output = ['# Generated by sshush']
31+
output = []
3232

3333
defaults = extract_section('default', ssh_config_yaml, {})
3434
global_values = extract_section('global', ssh_config_yaml)

0 commit comments

Comments
 (0)