mirror of
https://github.com/not-kennethreitz/click-tools.git
synced 2026-06-05 23:20:19 +00:00
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
def piped_in():
|
||||
"""Returns piped input via stdin, else None."""
|
||||
with sys.stdin as stdin:
|
||||
# TTY is only way to detect if stdin contains data
|
||||
if not stdin.isatty():
|
||||
return stdin.read()
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def is_interactive():
|
||||
"""Returns if the current session is interactive or not."""
|
||||
return bool(os.isatty(sys.stdout.fileno()))
|
||||
Reference in New Issue
Block a user