Skip to main content

wip pypi pypi-version travis-ci Code Climate Test Coverage Open Source Love

sherlock.py

Sherlock.py is transpiler that translate python to shell script language.

한국어로 보기

Motivation

map to buried treasure

< Ditective who program with Shell script >

Shell script is well known script language which is used in most of unix-like OS. Shell script lanuage garuntee to run in most unix-like OS. So many software developers are using this language when they program install script or configuration script. Because this language is really old, There are several problems. and it is hard to maintain program which is writted by Shell script language.

Install

$ pip install sherlock.py

Sherlock.py supports python version over 2.6 or 3.3. and support linux and macOS. If there is error in install please write issue.

Usage

usage: sherlock [-h] [-o output] [-c] [-v] [--version] [file | command]

Python to bash trans-compiler.

positional arguments:
  [file | command]  program read from script file

optional arguments:
  -h, --help        show this help message and exit
  -o output         output file path
  -c, --command     program passed in as string
  -v, --verbose     program run in verbose mode
  --version         show program's version number and exit

Following is basic usage.

$ sherlock target.py

Using this command, target.py file is translated into shell sciprt. after, it is automatically run with sh. We can find out bug from the running result.

$ sherlock target.py -o output.sh

Using -o flag, you can save sherlock result in file. In this case script isn’t run automatically.

$ sherlock -c "echo 'Hello World.'"

Using -c flag, input command is immediately translated to shell script language and executed.

If you want to details. Please check sample codes

Library

sherlock.cmd package

You can use general shell command importing from sherlock.cmd. When you import package, it check user already installed command and create wrap function which return stdout output.

from sherlock.cmd import ls
ls('-al')

pipe function

In shell script, you can combine command with | operator. To do same thing in python, Sherlock.py support pipe function.

from sherlock.cmd import wc
pipe(print('./test'), wc('-c'))

Todo

  • import syntax

  • command package

  • documentation

  • support windows batch and powershell script

  • more test…

License

  • MIT © 2017 Luavis

  • Icon designed by cyoh, Sherlock Holmes graphic by Matthew Davis from the Noun Project

Release files for sherlock.py 0.3.0

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

Source distribution (sdist)

Source distribution for sherlock.py 0.3.0
File Size Uploaded
sherlock.py-0.3.0.tar.gz 12.2 kB Details

Release files / sherlock.py-0.3.0.tar.gz

Download URL sherlock.py-0.3.0.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8c206a1207b1a87aa260251ebadac81a5c97353558d30d185fba51998638a3ec
BLAKE2b-256 checksum
How to use checksums
2024012e6a734e72be6059c115316f5ee255af3ebef7a2ccb97a3319c6e2a93b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

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