Skip to content

jkomalley/convbase

Repository files navigation

convbase

PyPI - Status PyPI - Version PyPI - License PyPI - Python Version CI

A command-line utility for converting integers between binary, octal, decimal, and hexadecimal bases.

Installation

pip install convbase

Or with uv:

uv tool install convbase

Commands

Command Output base
bin Binary (0b)
oct Octal (0o)
dec Decimal
hex Hexadecimal (0x)

Input formats

All commands accept VALUE in any of the following formats:

Format Prefix Example
Decimal (none) 10
Binary 0b 0b1010
Octal 0o 0o12
Hexadecimal 0x 0xA

Examples

$ bin 10
0b1010
$ bin 0xFF
0b11111111

$ oct 0b1010
0o12
$ oct 0xA
0o12

$ dec 0b1010
10
$ dec 0xFF
255

$ hex 10
0xa
$ hex 0b11111111
0xff

Error handling

Passing a value that cannot be parsed as an integer exits with a non-zero status and prints an error:

$ bin hello
Error: Invalid value for 'VALUE': invalid integer: 'hello'

Development

git clone https://github.com/jkomalley/convbase
cd convbase
just setup
just all       # lint, type-check, and test

License

MIT

About

Base conversion command line utility.

Topics

Resources

License

Stars

Watchers

Forks

Contributors