This is a development environment based on Blockly where users can easily construct data processing pipelines by visually plugging together processing blocks. The pipeline will be implemented underneath using Unix tools.
The purpose of this project is to present a unique framework that makes use of Blockly, a visual programming language, to represent Unix commands as graphical blocks and to convey their abstractions. Through simplifying the way of their operation and the elimination of the requirement for specialist programming expertise, this method intends to make Unix utilities more accessible to a wider audience.The thesis provides an explanation of the development of a visual programming interface that simplifies the utilization of Unix command-line tools by allowing users to design data processing pipelines by dragging and dropping components. Visual blocks are connected to Unix instructions through the use of JSON specification files, which are utilized by the system in order to facilitate the conversion process.
The user-friendliness of data processing activities is improved as a result of this deliberate design choice, and users are encouraged to develop a deeper understanding of Unix commands. Increasing the accessibility of complex data manipulation is one of the goals of this initiative, which also aims to encourage more people to participate in computational data analysis.The findings of the project underline the significance of visual programming in the process of combining complex command-line activities with user-friendly interfaces. This, in turn, broadens the range of tools that are available to data scientists and researchers working in a variety of fields. This research not only makes a contribution to the field of visual programming, but it also opens up new possibilities for instructional tools that facilitate the acquisition of command-line interfaces using approaches that are both interactive and interesting.
To run UBlocks on a local server, navigate to the top-level directory and start the development server by running the following command:
npm run devStart
To ensure that code is properly formatted before committing, set up the pre-commit hook by following these steps :
-
Run the following command at the top-level directory :
printf '#!/bin/sh\nbin/pre-commit\n' > .git/hooks/pre-commit
-
Make both scripts executable through the following command :
chmod +x .git/hooks/pre-commit bin/pre-commit
Below are the instructions on how to create a new block in a separate file (e.g., [blockName]Block.js
), and how to integrate it into the existing code generation system (UnixGenerator
) that we have already implemented.
Inside the folder where you keep your blocks (blocks/
), create a new file named [blockName]Block.js
.
For instance, if you want to create a block for a command called foo
, you can name it fooBlock.js
.
In this new file, define your block using the JSON schema required by Blockly. Below is a basic structure:
var fooBlock = {
type: 'foo', // Unique name for the block
category: 'My Custom Category', // Category in which the block will appear in the toolbox
unix_description: [
// The "unix_description" array defines how totranslate the block into a Unix command.
{
foo: 'customFoo',
printName: true, // "printName" specifies whether the block's type should appear explicitly in the generated command.
// Static Handling
myStaticField: '-s',
myDynamicField: (fieldValues) => {
// Example: Append the field value with a prefix
return `--option=${fieldValues['myDynamicField']}`;
}
}
],
message0: 'Message displayed on the block %1',
args0: [
{
type: 'field_input',
name: 'myStaticField',
text: 'default value'
}
],
message1: 'Message displayed on the block %1',
args1: [
{
type: 'field_input',
name: 'myDynamicField',
text: 'default value'
}
],
// Configuration for block connections (input, output, statement, etc.)
previousStatement: 'Action',
nextStatement: 'Action',
style: 'My Custom Category',
tooltip: 'Description of what this block does',
helpUrl: '' // Optional: link to further documentation
};
// Register the block with Blockly
Blockly.defineBlocksWithJsonArray([fooBlock]);
// Register the generator handler for this block
window.unixGenerator.forBlock['foo'] = window.unixGenerator.forBlock.generic;
In the UnixGenerator architecture, each Blockly block has an associated unix_description
, which describes how its fields (fieldValues
) and child blocks (childCode
) should be translated into a Unix command. Also it is crucial that the keys used in unix_description correspond exactly to the names of the fields defined in args. This ensures that the generator can correctly map field values to their respective parts in the Unix command. Below is a high-level overview of how this works:
- Typically,
unix_description
is an array of one or more objects. Each object specifies functions and/or flags that define how to compose the final command. - Example:
unix_description: [ { printName: true, // Determines if the block's type should be printed in the command someFieldName: '-f', // Static string to be added if the field is active // Function to dynamically process fieldValues and childCode someInputStatementName: (fieldValues, childCode) => { // process fieldValues and childCode return `-x ${childCode}`; } } ];
- Functions: If you need to dynamically combine or manipulate
fieldValues
andchildCode
, you can define a function inunix_description
:This function will be called by the generator, and whatever string it returns will be appended to the command.someFieldName: (fieldValues, childCode) => { return `-o ${fieldValues['someParam']} ${childCode}`; };
- Static Strings: If you only need a fixed flag (e.g.,
-r
,--verbose
), you can simply specify a string:The generator will automatically addsomeFieldName: '-r';
-r
when the corresponding field is “checked” or “selected,” depending on your field definition.
- In your main generator setup, you decide how each block’s code is combined with subsequent blocks. You can choose:
or
window.unixGenerator.forBlock['foo'] = window.unixGenerator.forBlock.generic;
window.unixGenerator.forBlock['foo'] = window.unixGenerator.forBlock.concat;
generic
: This handler typically adds a pipe symbol (|
) between commands, following the standard Unix “piping” convention.concat
: This handler concatenates the output without a pipe or spaces, or uses a different connector if defined. It’s useful for scenarios where multiple arguments are strung together (e.g., building up a filename or a single argument line).
Specifying the Block's Name in unix_description
:
You can override the default block name in the generated command by specifying a different key in unix_description
. For example:
unix_description: [
{
foo: 'customFoo', // Instead of printing 'foo', it will print 'customFoo' in the command
printName: true
}
];
In this case, if the block's type is 'foo' and you set 'foo': 'customFoo' in unix_description, the generated command will include 'customFoo' instead of 'foo'. 3. Format the code by running the following command:
npm run prettier-fix
The work behind this project is further documented in MSc theses by Klenti Cipi and Pantelis Kakavas.