Skip to main content

Installing

pip3 install flagopt

Battleship

import flagopt

usage = '-x [spot] -y [spot]'

flags = flagopt.trace(usage)

content = '-x C -y 7'

args = flagopt.snip(flags, content)

print('hit at', args['-x'], args['-y'])

Actions

import flagopt

flags = {
  '-move': {
    '-x': 'distance',
    '-y': 'distance'
  },
  '-craft': 'recipe',
  '-scavenge': {
    '-target': 'resource',
    '-finish': {
      '-time': 'hours',
      '-time': 'amount'
    }
  },
  '-rest': 'hours',
  '-target': 'human | animal'
}

# show how to use this
usage = flagopt.draw(flags)

content = (
  # move right linearly
  '-move -x 10 '
  # then move diagonally right and down;
  # no need to explicitly pass the first flag (-x)
  '-move 5 -y -5 '
  # backslash is used as an escape character;
  # -target will be ignored during the first parse scan
  # and the backslash will be removed so that -target can
  # be considered during the next scan for -scavenge;
  # multiple backslashes can be used to achieve other
  # amounts of iterations for this effect
  '-scavenge \-target wood '
  # arguments can be passed multiple times (-time);
  # scavenge for 3 hours and 60 more wood after that
  '-finish -time 3 -limit 60 '
  # or until 5 hours have passed
  '-finish -time 5'
  # rest for 4 hours, craft a tent, rest for another 3;
  # there is no space between 5 and -rest (line above);
  # spaces do not matter for flags and are stripped away
  # unless there is an escape character before / after
  '-rest 4      '
  # you can pass empty flags,
  # their presence is indicated with an empty string
  '--debug '
  # im bad at coming up with examples
  '-craft spear '
  # especially when they involve games
  '-target rabbit '
  # time to sleep now
  '-rest 3'
)

args = flagopt.snip(flags, content)

moves = args.getall('-move')

print(moves)

Metadata

Release files for flagopt 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flagopt 0.1.4
File Size Uploaded Provenance Actions
flagopt-0.1.4.tar.gz 5.1 kB Without provenance Details for flagopt-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flagopt 0.1.4
File Interpreter ABI Platform Actions
flagopt-0.1.4-py3-none-any.whl Python 3 none any Details for flagopt-0.1.4-py3-none-any.whl

Total release size: 10.9 kB

Release files / flagopt-0.1.4.tar.gz

Download URL flagopt-0.1.4.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
caa84e6968fbab47e1bea773b5fbe30222841cf9a98f30ef720efd15119dac09
BLAKE2b-256 checksum
How to use checksums
22a3eb07a35dc631e03e73c4b97a81212e795c8a0f5aeca03f2f49ee849ca876
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

Release files / flagopt-0.1.4-py3-none-any.whl

Download URL flagopt-0.1.4-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88943c3cb875bc64018766d8ce5668d65936c0fd15509da70d96eb3f8a8c0e3d
BLAKE2b-256 checksum
How to use checksums
ca2d63592c26ff08e73f7320aa7dcb5dd9ff0d5be5d8cc2573ed8e4da62d97c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

Security for flagopt 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page