#!/bin/bash

function gc_login()
{
    gcloud cloud-shell ssh --authorize-session
}

function gc_get()
{
    if [ "$3" == "" ]; then
        gcloud cloud-shell scp cloudshell:"$2" localhost:"$2"
    else
        gcloud cloud-shell scp cloudshell:"$2" localhost:"$3"
    fi
}

function gc_post()
{
    if [ "$3" == "" ]; then
        gcloud cloud-shell scp localhost:"$2" cloudshell:"$2"
    else
        gcloud cloud-shell scp localhost:"$2" cloudshell:"$3"
    fi
}

function gc_mount()
{
    gcloud cloud-shell get-mount-command ~/Public/my-cloud-shell
}

case $1 in
    login)
        gc_login
        ;;
    get|pull)
        gc_get "$@"
        ;;
    post|push)
        gc_post "$@"
        ;;
    mount)
        gc_mount
        ;;
esac
