A Lightweight tool for writing and running scripts(Version-1.0)
===
You have to install Python3
:
You should check the package tkinter
is already installed.(Do not worry! tkinter
is a default package of Python)
Just download from github tarball:
It's easy, just type:
$ ./sk
and you will see the friendly interface of script-king.
Following is the graph of script-king main window():
There are 5 area in the main window:
- Window title: list tool's name, version and the current file name.
- Menu bar: including all functions.
- Token area: list the existing tokens and you can also create/delete/edit/move a token by the buttons aside.
- Script editor: write the main script here with normal text and the token set already.
- status bar: show the status of each actions.
Let me show you how to use and when to use script-king by a simple example.
First, assume you have a exutable file(command) named "DOIT".
This command takes a file name as its parameter.
Like that:
$ DOIT FILE_NAME
Now, you have to run it with 100 files in directory "bench":
bench
|--f1
|--f2
|--f3
|...
|--f100
I think you do not want to type the command 100 times.
What can you do?
Maybe a script: bash script, python script, ...
Oh, but you are not familiar with any kind of script.(Yes, you are the expected user of script-king.)
Or you think write the normal script is a trouble.
The answer is ... using script-king!
First, we have to set a token to reprents these 100 files.
Click "create" button and you will see a token window:
Let's fill in some input fields to create a token:
- Symbol: eacn token needs a symbol, now we choose
#
asSymbol
. - Type: we want to iterate all file names of the directory "bench", so we type "iter" as
Type
. - Click
Choose
button to choose the target directory "bench" or you can type it by yourself.(complete path is needed) - Click
Preview
button to check the results, you should see the first 5 files' name in the previewer. - Click
Ok
button to create this new token.
You will see a new token in the token list of main window.
Now, let us write the script in script editor:
DOIT #
Then do run
in the menu.
Greate! All commands are excuted!
If you are familar with the process, it is really fast and simple(than any other scripts).
Token is a main object of script-king.
We use token's symbol to represent some values.
You can simply think tokens are like variables.
You can use button Create
or Create
option in menu to create a new token.
Choose an existing token then it can be edited by the Edit
button or Edit
option in menu.
Choose an existing token then use Delete
or Delete
option in menu to remove it.
A symbol is like a literal.
We would use symbols to represent something in our scripts.
A letter, a word, or any syntax is avalible.
But the blanks are not allowed for symbol.
There are 3 types of token.
fix
: this token just represents a constant string, it is usually used to represent a directory name.
iter
: this token represents the files names in a specified directory.
num
: this token represents numbers from the specifed range.
After setting symbol, its type and its value, you can click Preview
to check the first 5 items of this token.
Filter allows user to reserve some items and remove the others from a token. It uses the if statement of python.
For example, if we want to resere the file names which contain string '.f' from a token whose symbol is #.
We can write following sentence in filter:
if '.f' in '#'
note that the symbol should be in the single quotation marks ''.
script-king also supports other python statements.
Choose the Run and catch
option in menus to run the script and save the results to a specified file.
You can save the current project to a sk file and reload it after.
Choosethe