Skip to content

Instantly share code, notes, and snippets.

@esmaeelE
Last active February 18, 2025 07:57
Show Gist options
  • Save esmaeelE/195068619b8f1d90cc474fa174b73b1e to your computer and use it in GitHub Desktop.
Save esmaeelE/195068619b8f1d90cc474fa174b73b1e to your computer and use it in GitHub Desktop.
click cli read from stdin
#!/env/bin/python3
import click
import sys
@click.group()
def cli():
pass
@cli.command()
@click.option('--compose-file',
help='compose file to work with',
type=click.File('r'),
default=sys.stdin)
def secret_hash_ini(compose_file):
with compose_file:
data = compose_file.read()
print(data, end='')
if __name__ == '__main__':
cli()
# Run
# echo thisistest | ./run.py secret-hash-ini
# based on [larsks' aswer on SO](https://stackoverflow.com/a/59830073)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment