Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 162792a1 authored by Freezed's avatar Freezed
Browse files

:construction: WIP: Add a command and retrieve GPX info

parent 6d2b44d7
No related branches found
No related tags found
No related merge requests found
......@@ -21,72 +21,27 @@ from strava.formatters import (
)
from api import post_activity
import gpx
_ACTIVITY_COLUMNS = ("key", "value")
_ACTIVITY_COLUMNS = ("key", "value")
DEFAULT_DESC="Made with 🤖 https://lab.frogg.it/fcode/geostrapy/"
DEFAULT_NAME="Geostrapy activity 🤖"
@click.option(
"-n",
"--name",
prompt=True,
type=str,
required=True,
default="Activity",
help="The name of the activity",
)
@click.option(
"-a",
"--activity_type",
prompt=True,
type=str,
required=True,
default="run",
help="Type of activity",
)
@click.option(
"-s",
"--start",
prompt=True,
type=str,
required=True,
default=datetime.datetime.now().isoformat(),
help="ISO 8601 formatted date time",
)
@click.option("-t", "--time", prompt=True, type=int, required=True, help="In seconds")
@click.option("-d", "--desc", prompt=True, type=str, help="Description of the activity")
@click.option("-a", "--activity_type", prompt=True, type=str, required=True, default="run", help="Type of activity",)
@click.option("-c", "--commute", prompt=True, type=int, default="0", prompt_required=False, help="Set to 1 to mark as commute",)
@click.option("-d", "--desc", prompt=True, type=str, default=DEFAULT_DESC, help="Description of the activity")
@click.option("-D", "--dist", prompt=True, type=int, help="In meters")
@click.option(
"-c",
"--commute",
prompt=True,
type=int,
default="0",
prompt_required=False,
help="Set to 1 to mark as commute",
)
@click.option(
"-T",
"--trainer",
prompt=True,
type=int,
default="0",
prompt_required=False,
help="Set to 1 to mark as a trainer activity",
)
@click.option(
"-h",
"--hide",
prompt=True,
type=int,
default="0",
prompt_required=False,
help="Set to true to mute activity",
)
@click.command("create")
@click.option("-h", "--hide", prompt=True, type=int, default="0", prompt_required=False, help="Set to true to mute activity",)
@click.option("-n", "--name", prompt=True, type=str, required=True, default="Activity", help="The name of the activity",)
@click.option("-s", "--start", prompt=True, type=str, required=True, default=datetime.datetime.now().isoformat(), help="ISO 8601 formatted date time",)
@click.option("-t", "--time", prompt=True, type=int, required=True, help="In seconds")
@click.option("-T", "--trainer", prompt=True, type=int, default="0", prompt_required=False, help="Set to 1 to mark as a trainer activity",)
@click.command("mcreate")
@output_option()
@login_required
def post_create(**kwargs):
"""Create an activity (manually)."""
def post_create_manu(**kwargs):
"""Create an manual activity."""
xargs = {
"name": kwargs["name"],
"type": kwargs["activity_type"],
......@@ -126,9 +81,28 @@ def _as_table(upload_result):
"errors": format_error,
}
basic_data = [
{"key": format_property(k), "value": v}
for k, v in apply_formatters(upload_result, formatters).items()
]
basic_data = [{"key": format_property(k), "value": v} for k, v in apply_formatters(upload_result, formatters).items()]
return [*basic_data]
"""
@click.option("-a", "--activity_type", type=str, help="Type of activity",)
@click.option("-c", "--commute", type=int, default="0", help="Set to 1 to mark as commute",)
@click.option("-d", "--desc", type=str, default=DEFAULT_DESC, help="Description of the activity",)
# @click.option("-D", "--dist", type=int, help="In meters",)
@click.option("-h", "--hide", type=int, default="0", help="Set to true to mute activity",)
@click.option("-n", "--name", type=str, required=True, default=DEFAULT_NAME, help="The name of the activity",)
# @click.option("-s", "--start", type=str, required=True, default=datetime.datetime.now().isoformat(), help="ISO 8601 formatted date time",)
# @click.option("-t", "--time", type=int, required=True, help="In seconds",)
@click.option("-T", "--trainer", type=int, default="0", help="Set to 1 to mark as a trainer activity",)
@output_option()
"""
@click.argument('gpx_filename', type=click.Path(exists=True))
@click.command("fcreate")
@login_required
def post_create_file(gpx_filename):
"""Create an manual activity from a GPX file."""
click.echo(f"Processing: {click.format_filename(gpx_filename)}")
click.echo(f"Summary: {gpx.run([gpx_filename])}")
cli/main.py 100644 → 100755
......@@ -13,7 +13,7 @@ from strava.commands import (
set_config,
)
from commands import post_create
from commands import post_create_file, post_create_manu
@click.group()
......@@ -23,7 +23,8 @@ def cli():
cli.add_command(login)
cli.add_command(logout)
cli.add_command(post_create)
cli.add_command(post_create_manu)
cli.add_command(post_create_file)
cli.add_command(set_config)
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment