Skip to content

Commit

Permalink
fix: Make the CLI interface more self-documenting.
Browse files Browse the repository at this point in the history
  • Loading branch information
skorokithakis committed Apr 25, 2016
1 parent a1f3bb2 commit 06d2aea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
33 changes: 18 additions & 15 deletions catt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@


@click.group()
@click.option("--delete-cache", is_flag=True)
@click.option("--delete-cache", is_flag=True, help="Empty the Chromecast "
"discovery cache. Specify this if you're having errors connecting to "
"the Chromecast.")
def cli(delete_cache):
if delete_cache:
Cache().clear()


@cli.command()
@cli.command(short_help="Send a video to a Chromecast for playing.")
@click.argument("video_url")
def cast(video_url):
stream_url = get_stream_url(video_url)
Expand All @@ -21,32 +23,33 @@ def cast(video_url):
cast.play_media(stream_url)


@cli.command()
def play():
CastController().play()


@cli.command()
@cli.command(short_help="Pause a video.")
def pause():
CastController().pause()


@cli.command()
@cli.command(short_help="Resume a video after it has been paused.")
def play():
CastController().play()


@cli.command(short_help="Stop playing.")
def stop():
CastController().kill()


@cli.command()
def rewind():
CastController().rewind()
@cli.command(short_help="Rewind a video by SECS seconds.")
@click.argument("seconds", type=click.INT, required=False, default=30, metavar="SECS")
def rewind(seconds):
CastController().rewind(seconds)


@cli.command()
@click.argument("seconds")
@cli.command(short_help="Seek the video to SECS seconds.")
@click.argument("seconds", type=click.INT, metavar="SECS")
def seek(seconds):
CastController().seek(seconds)


@cli.command()
@cli.command(short_help="Show some information about the currently-playing video.")
def status():
CastController().status()
6 changes: 1 addition & 5 deletions catt/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ def stop(self):
def seek(self, seconds):
self.cast.media_controller.seek(int(seconds))

def rewind(self, seconds=None):
try:
seconds = int(seconds)
except:
seconds = 30
def rewind(self, seconds):
pos = self.cast.media_controller.status.current_time
self.seek(pos - seconds)

Expand Down

0 comments on commit 06d2aea

Please sign in to comment.