#!/usr/bin/env python3
#
# remt - reMarkable tablet tools
#
# Copyright (C) 2018 by Artur Wroblewski <wrobell@riseup.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

import argparse
import asyncio

import remt.cmd

desc = 'remt - reMarkable tablet tools'

parser = argparse.ArgumentParser(description=desc)
main_parser = parser.add_subparsers(dest='subcmd')

# command: ls
sub_parser = main_parser.add_parser('ls')
sub_parser.add_argument(
    '-l',
    dest='long',
    action='store_true',
    default=False,
    help='Use long listing format',
)
sub_parser.add_argument(
    '-R',
    dest='recursive',
    action='store_true',
    default=False,
    help='List subdirectories recursively',
)
sub_parser.add_argument('path', nargs='?', help='Starting path')

# command: mkdir
sub_parser = main_parser.add_parser('mkdir')
sub_parser.add_argument('path', help='Directory to create')

# command: export
sub_parser = main_parser.add_parser('export')
sub_parser.add_argument('input', help='Path of file to download')
sub_parser.add_argument('output', help='Output filename')

args = parser.parse_args()

cmd = remt.cmd.COMMANDS.get(args.subcmd)
if cmd is None:
    parser.print_usage()
    parser.exit()

loop = asyncio.get_event_loop()
loop.run_until_complete(cmd(args))

# vim: sw=4:et:ai
