sheagcraig / yo

Send Notification Center messages from the command line
Apache License 2.0
384 stars 44 forks source link

Display --help output if no arguments are provided #26

Open homebysix opened 6 years ago

homebysix commented 6 years ago

Current behavior when no arguments are provided to yo_scheduler:

$ /usr/local/bin/yo_scheduler
Traceback (most recent call last):
  File "/usr/local/bin/yo_scheduler", line 294, in <module>
    main()
  File "/usr/local/bin/yo_scheduler", line 153, in main
    run_yo_with_args(yo_args)
  File "/usr/local/bin/yo_scheduler", line 181, in run_yo_with_args
    call(args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Perhaps a more desirable behavior would be to display the --help output:

$ /usr/local/bin/yo_scheduler
usage: yo_scheduler [-h] [--cached] [--cleanup]

Yo launcher arguments:

optional arguments:
  -h, --help  show this help message and exit
  --cached    Run cached notifications (must be run as console user). This
              option is normally run by the LaunchAgent and is not intended
              for interactive use.
  --cleanup   Remove all cached notifications (must be run as root).

    Yo app notification options:
    -t, --title:
        Title for notification. REQUIRED.
    -s, --subtitle:
        Subtitle for notification.
    -n, --info:
        Informative text.
    -b, --action-btn:
        Include an action button, with the button label text supplied to this
        argument.
    -a, --action-path:
        Application to open if user selects the action button. Provide the full
        path as the argument. This option only does something if
        -b/--action-btn is also specified.
    -B, --bash-action:
        Bash script to run. Be sure to properly escape all reserved characters.
        This option only does something if -b/--action-btn is also specified.
        Defaults to opening nothing.
    -o, --other-btn:
        Alternate label for cancel button text.
    -i, --icon:
        Complete path to an alternate icon to use for the notification.
    -c, --content-image:
        Path to an image to use for the notification's 'contentImage' property.
    -z, --delivery-sound:
        The name of the sound to play when delivering or 'None'. The name must
        not include the extension, nor any path components, and should be
        located in '/Library/Sounds' or '~/Library/Sounds'. (Defaults to the
        system's default notification sound). See the README for more info.
    -d, --ignores-do-not-disturb:
        Set to make your notification appear even if computer is in
        do-not-disturb mode.
    -l, --lockscreen-only:
        Set to make your notification appear only if computer is locked. If
        set, no buttons will be available.
    -p, --poofs-on-cancel:
        Set to make your notification 'poof' when the cancel button is hit.
    -m, --banner-mode:
        Does not work! Set if you would like to send a non-persistent
        notification. No buttons will be available if set.
    -v, --version:
        Display Yo version information.
homebysix commented 6 years ago

On subsequent runs, I realize the OSError is an unrelated issue on my Mac. Same thing happens with --version:

$ /usr/local/bin/yo_scheduler --version
Traceback (most recent call last):
  File "/usr/local/bin/yo_scheduler", line 294, in <module>
    main()
  File "/usr/local/bin/yo_scheduler", line 125, in main
    run_yo_with_args(yo_args)
  File "/usr/local/bin/yo_scheduler", line 181, in run_yo_with_args
    call(args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

My initial suggestion to display --help by default stands, though. Sorry for the confusion.

sheagcraig commented 6 years ago

Aha! Yes @homebysix. I'm working through some polish with @mikemackintosh to solve this.

But this is probably because you didn't install Yo in the "normal" location.