<reponame>swordysrepo/youtube_discord_bot<gh_stars>1-10
# youtube_api.py
import click
from src.command_prompt.cli_command_ch import channel_proc
from src.command_prompt.cli_command_srch import search_proc
from pprint import pprint
@click.group(invoke_without_command=True)
@click.pass_context
def cli(ctx):
    if ctx.invoked_subcommand is None:
        # click.echo('I was invoked without subcommand')
        click.echo('invoke without subcommand')

    else:
        # click.echo(f"I am about to invoke {ctx.invoked_subcommand}")
        click.echo(f"invoke {ctx.invoked_subcommand} command")




    
@cli.command()
@click.argument('search')
@click.argument("list_name",default="default")
def search(search,list_name):
    ''' search youtube with a query '''
    click.echo(f"search query {search} using list {list}")
    search_results = search_proc.start(search,list_name)
    for i in range(len(search_results)):
        print(f"{search_results[i]['channel']} --- {search_results[i]['title']}")
        print(f"{search_results[i]['video_link']}\n\n")
    # pprint(search_results)

    
@cli.command()
@click.argument('channel')
@click.argument('list_name', default = "default")
def addchannel(channel, list_name):
    ''' add a channel to the stored list '''
    click.echo(f"channel entered was {channel}")
    channel_proc.start(channel,list_name)

@cli.command()
@click.argument('list', default="default")
def list(list = "default"):
    ''' list the currently stored channels '''
    click.echo(f"list called was {list}")
    click.echo(f"echo stored channels in {list}")
