import
This commit is contained in:
commit
c8a4ebbbde
3 changed files with 54 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*.pyc
|
||||||
|
__pycache__
|
44
over-hex.py
Executable file
44
over-hex.py
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Library imports
|
||||||
|
import over
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Local imports
|
||||||
|
import version
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Exceptions
|
||||||
|
|
||||||
|
class ConfigurationError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Functions
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
# Classes
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main = over.app.Main("over-hex", version.str, "AO-JST", features={"config_file": True})
|
||||||
|
main.add_option("color", "Use colors.", bool, [True], abbr="C")
|
||||||
|
main.add_option("header", "Show a header (byte numbers).", bool, [True], abbr="H")
|
||||||
|
main.add_option("offsets", "Show a column of offsets (line numbers).", bool, [True], abbr="O")
|
||||||
|
main.add_option("ascii", "Show an ASCII translation (text).", bool, [True], abbr="A")
|
||||||
|
main.add_option("offset", "How many bytes per line of output to show.", int, [16], count=1, abbr="o")
|
||||||
|
main.add_option("seek", "Byte number at which output starts.", int, [0], count=1, abbr="s")
|
||||||
|
main.add_option("to", "Byte number where output ends. Use <m>0<.> to read the whole file but keep in mind that it has to fit in memory.", int, [10240], count=1, abbr="t")
|
||||||
|
|
||||||
|
main.add_doc("Description", ["A much less painful alternative to hexdump(1)."])
|
||||||
|
main.setup()
|
||||||
|
|
||||||
|
for target in main.targets:
|
||||||
|
with open(target, "rb") as f:
|
||||||
|
f.seek(main.cfg.seek)
|
||||||
|
data = f.read(main.cfg.to - main.cfg.seek)
|
||||||
|
|
||||||
|
over.misc.hexdump(data, offset=main.cfg.offset, show_header=main.cfg.header, show_offsets=main.cfg.offsets, show_ascii=main.cfg.ascii, use_colors=main.cfg.color, initial_offset=main.cfg.seek)
|
8
version.py
Normal file
8
version.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
major = 0 # VERSION_MAJOR_IDENTIFIER
|
||||||
|
minor = 1 # VERSION_MINOR_IDENTIFIER
|
||||||
|
# VERSION_LAST_MM 0.1
|
||||||
|
patch = 0 # VERSION_PATCH_IDENTIFIER
|
||||||
|
str = "0.1.0" # VERSION_STRING_IDENTIFIER
|
Loading…
Add table
Add a link
Reference in a new issue