Skip to content

Zipped Command Line is a software utility to share your files with anybody using the command line!.

Notifications You must be signed in to change notification settings

PratyushMakkar/ZippedCommandLine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💬 Zipped Command Line

Zipped Command Line is a software utility to share your files with anybody using the command line!

The software is based on MongoDB, Firebase storage and using Python FastAPI for the backend server.

If you have ideas to improve the software or add new features, feel free to create a pull request.

📥 Dependancies And Installation

The service can be used as a pip package. First compile all the dependancies for the project. You can create a Click Command Line application by following these steps

  1. cd zipped_cli
  2. pip install editable .

Verify that the tool is installed by using the command

zipped login

You should then be prompted to login using a username and password.

🔌 Tool Documentation

Creating a new user using Zipped login

To create a new user, simply use the command zipped login --new. You will then be prompted to create a user-id and password. Here is an example below,

Alt text

Note that a new folder named Zipped will created in your home desktop. This folder will contain a configuration file named config.json

Logging in using an existing user/password

To log in with an existing user ID, simply omit the --new flag. You will then be prompted to login and confirm your username and password.

Alt text

Viewing recieved files

In the above example, we have also shown how to view files. Using the command zipped file. The file will contain a list including the URL, which can be used alongside the download command.

Uploading a file

To upload a file, you can use the command zipped upload {fileLocation} --recipient. The recipeint flag is used to specify to whom you would like to send the file to. The file location must be relative the user in Unix operating systems. Here is an example of the command,

Alt text

Downloading a file using zipped download

To download a file, use the command zipped download {url}. Here is an example below,

Alt text

The file is automatically added to your desktop folder Zipped and later deleted within the server.

📌 Technical Documentation

The state date for each request is stored in an object named Configuration class that is passed through the context object for each request.

class Configuration(object):
    def __init__(self, _home, _path) -> None:
        self.home = _home
        self.path = _path
        self.configIO: ConfigIO = ConfigIO(path = _path)
        self.username = None
        self.password = None

For example, within the zipped file command, the stored context object retrieves the username and password from a config.json file stored in the home zipped folder. This decision is made to avoid forcing the user to pass the username and password with each request.

@click.command()
@click.option("--count")
@click.pass_context
def file(ctx, count:int = 3):
    config: Configuration = ctx.obj
    _username, _password = SanitizeUsernameAndPassword(config)

It is worth noting that some commands can be run without authentication. For example zip download when provided with a valid URL will be able to download the file onto your computer into the designated folder.

@click.command()
@click.option("--location", default = None)
@click.argument('url')
@click.pass_context
def download(ctx, location, url):

    if (not url):
        raise ZippedRuntimeException(detail= "A URL for the file must be specified")

    config: Configuration = ctx.obj
    _home = config.getHome()
    

To register the commands, a zipped group is made since all other commands access common zipped functionality.

import click 

@click.group()
@click.option("--home", default = _path)
@click.pass_context
def zipped(ctx, home: str):

    # If a home paramater is not specified then a dekstop Zipped folder created is used as home
    config_home = _CreateDesktopFolder()

To render the styled terminal ASCII art,

click.secho("The file has been uploaded and can be found at {0}".format(download_url), fg='green')

To understand API requests, refer to the folder zipped_cli/api/

def POSTFileToServer(filepath: str, id: str):
    url = "{0}/{1}?id={2}".format(SERVER_URL, Resource._UPLOAD, id)

    with open(filepath, 'rb') as file:
        files = {'file' : file}
        response = requests.post(url, files=files)  
    return response
    

Here is a snapshot of the expected server requests,

Alt text

🛠️ Contributing to the project

If you would like to contribute to the project, feel free to create a pull request. Make sure that all documentation is present for any changes.

📜 License

The library is licensed under GNU GENERAL PUBLIC LICENSE

About

Zipped Command Line is a software utility to share your files with anybody using the command line!.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published