Skip to main content

Command Line Interface for PyScript

Project description

PyScript CLI

A command-line interface for PyScript.

Version Test codecov pre-commit.ci status Checked with mypy

Quickly wrap Python scripts into a HTML template, pre-configured with PyScript.

 pyscript

 Usage: pyscript [OPTIONS] COMMAND [ARGS]...

 Command Line Interface for PyScript.

╭─ Options ──────────────────────────────────────────────────────────────────────────────────────╮
│ --version          Show project version and exit.                                              │
│ --help             Show this message and exit.                                                 │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────╮
│ create  Create a new pyscript project with the passed in name, creating a new directory in the │
│         current directory. Alternatively, use `--wrap` so as to embed a python file instead.   │
│ run     Creates a local server to run the app on the path and port specified.                  │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯

Installation

Using Pip

$ pip install pyscript

Installing the developer setup from the a repository clone

see the Developer setup section on CONTRIBUTING page

Usage

run

Spin up a local server to run on the path and specified port

$ pyscript run <path_of_folder>

This will serve the folder path_of_folder at localhost:8000 by default and will open the URL in a browser window. Default is current directory if path_of_folder is not supplied.

To use a different port, use --port option.

$ pyscript run <path_of_folder> --port 9000

To avoid opening a browser window, use --no-view option.

$ pyscript run <path_of_folder> --no-view

create

Create a new pyscript project with the passed in name, creating a new directory

$ pyscript create <name_of_app>

This will create a new directory named name_of_app under the current directory.

The interactive prompts will further ask for information such as description of the app, name of the author, email of the author, etc. These of course can be provided via options such as --author-name etc. Use pyscript create --help for more information.

The following files will be created:

  • index.html: start page for the project
  • pyscript.toml: project metadata and config file
  • main.py: a "Hello world" python starter module

Use --wrap to embed a python file OR a command string

  • Embed a Python script into a PyScript HTML file
$ pyscript create --wrap <filename.py>

This will generate a project i.e. a new directory named filename under the current directory.

Similar to the above, interactive prompts will further ask for metadata information.

The following files will be created:

  • index.html: start page for the project
  • pyscript.toml: project metadata and config file
  • main.py: contains code of filename.py

This can be overridden with the -o or --output option:

$ pyscript create --wrap <filename.py> -o <another_filename.html>

i.e. the HTML file created in the above directory will now be named another_filename.html

  • Very simple command examples with --command option

The -c or --command option can be used to demo very simple cases.

By default, the name of the project folder created will be pyscript-command-app with the HTML file named index.html.

-o/--output option can be used with the -c/--command option to configure name of the project folder as well as the name of the resulting HTML file.

$ pyscript create --wrap -c 'print("Hello World!")' -o <output_filename.html>

This will generate a project i.e. a new directory named output_filename under the current directory.

Similar to the above, interactive prompts will further ask for metadata information.

The following files will be created:

  • output_filename.html: start page for the project
  • pyscript.toml: project metadata and config file
  • main.py: contains code of the command string passed via -c/--command

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyscript-0.3.2.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyscript-0.3.2-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file pyscript-0.3.2.tar.gz.

File metadata

  • Download URL: pyscript-0.3.2.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for pyscript-0.3.2.tar.gz
Algorithm Hash digest
SHA256 1c1ad2433f6c13b97122d9ffefc2d03b3cf34ba560c1425840519aff7dbb6d89
MD5 2a9a86e5ddcd778e4144a52b97a2c457
BLAKE2b-256 196193544b9b58b5e4cd6d3b3649ab34409ca876cfad420daab3a0348ea76c14

See more details on using hashes here.

File details

Details for the file pyscript-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: pyscript-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for pyscript-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6d86a525dc03319ef2f696a59239d742330112ca4149a882fcacc3cab6ddc205
MD5 9e3d3b990afa870c860bf974154f7033
BLAKE2b-256 b82b366b8fa82f918e77a08482124944c057bbb5ff8d166b59e8096c49f7e967

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page