Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Print functionality #1927

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/config/Categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,8 @@
"HTML To Text",
"Generate Lorem Ipsum",
"Numberwang",
"XKCD Random Number"
"XKCD Random Number",
"Print"
]
},
{
Expand Down
55 changes: 55 additions & 0 deletions src/core/operations/Print.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @author Joshua [ebert.joshua@protonmail.com]
* @copyright Crown Copyright 2024
* @license Apache-2.0
*/

import Operation from "../Operation.mjs";

/**
* Print operation
*/
class Print extends Operation {

/**
* Print constructor
*/
constructor() {
super();

this.name = "Print";
this.module = "Other";
this.description = "Prints a text to the output.";
this.infoURL = ""; // Usually a Wikipedia link. Remember to remove localisation (i.e. https://wikipedia.org/etc rather than https://en.wikipedia.org/etc)
this.inputType = "string";
this.outputType = "string";
this.args = [
{
name: "Text to print",
type: "string",
value: ""
},
{
name: "Replace",
type: "boolean",
value: true
}
];
}

/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const [text, replace] = args;
if (replace) {
return text.toString();
}
return input + text.toString();
}

}

export default Print;
Loading