Skip to content

Commit

Permalink
use argv[0] for autocommand name if func is run as __main__
Browse files Browse the repository at this point in the history
  • Loading branch information
mayfield committed Feb 18, 2023
1 parent 880c209 commit 01acbff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion shellish/command/autocommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import argparse
import inspect
import os.path
import sys
from . import command


Expand Down Expand Up @@ -110,7 +112,10 @@ def autocommand(func):
""" A simplified decorator for making a single function a Command
instance. In the future this will leverage PEP0484 to do really smart
function parsing and conversion to argparse actions. """
name = func.__name__
if func.__module__ == '__main__':
name = os.path.basename(sys.argv[0])
else:
name = func.__name__
title, desc = command.parse_docstring(func)
if not title:
title = 'Auto command for: %s' % name
Expand Down

0 comments on commit 01acbff

Please sign in to comment.