Skip to content

Commit

Permalink
Do not open /dev/null for no reason
Browse files Browse the repository at this point in the history
  • Loading branch information
alterakey committed Sep 3, 2024
1 parent 06b6bce commit dbba1b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion trueseeing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class FormatEntry(TypedDict):
class CommandHelper(Protocol):
def get_target(self) -> Optional[str]: ...
def require_target(self, msg: Optional[str] = None) -> str: ...
def get_context_type(self) -> Set[ContextType]: ...
def get_context_type(self) -> Optional[Set[ContextType]]: ...
@overload
def get_context(self) -> Context: ...
@overload
Expand Down
16 changes: 9 additions & 7 deletions trueseeing/app/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def invoke(self) -> int:
parser.add_argument('-d', '--debug', action='store_true', help='Debug mode')
parser.add_argument('-e', '--abort-on-errors', action='store_true', help='Abort on errors')
parser.add_argument('-F', dest='force_opener', help='Open target as specified format')
parser.add_argument('-n', dest='no_target', action='store_true', help='Open empty file')
parser.add_argument('-n', dest='no_target', action='store_true', help='Run without target')
args_mut0.add_argument('-i', dest='scriptfn', metavar='FILE', help='Run script file before prompt')
args_mut0.add_argument('-c', dest='inline_cmd', metavar='COMMAND', help='Run commands before prompt')
args_mut1.add_argument('-q', dest='mode', action='store_const', const='batch', help='Batch mode; quit instead of giving prompt')
Expand Down Expand Up @@ -109,12 +109,11 @@ def invoke(self) -> int:

ui.set_level(log_level)

if not args.fn:
if args.no_target:
args.fn = '/dev/null'
else:
parser.print_help()
return 2
if args.no_target:
args.fn = None
elif not args.fn:
parser.print_help()
return 2

if args.mode in ['inspect', 'batch']:
from trueseeing.app.inspect import InspectMode
Expand All @@ -138,6 +137,9 @@ def invoke(self) -> int:
force_opener=args.force_opener,
)
elif args.mode == 'scan':
if not args.fn:
ui.fatal('need target')

from trueseeing.core.exc import InvalidFileFormatError
try:
from trueseeing.app.scan import ScanMode
Expand Down

0 comments on commit dbba1b2

Please sign in to comment.