Skip to content

Commit 8792622

Browse files
Vitalii BulyzhynVitalii Bulyzhyn
authored andcommitted
Initial commit
0 parents  commit 8792622

7 files changed

Lines changed: 203 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

Readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Diffgram CLI
2+
3+
Readme is coming soon

bin/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env node
2+
const yargs = require("yargs")
3+
const create_action = require('./utils/action')
4+
5+
const usage = "\nDiffgram CLI:";
6+
const options = yargs
7+
.usage(usage)
8+
.command('action [NewActionName]', 'Creates a new Diffgram action', (yargs) => {
9+
yargs.positional('NewActionName', {
10+
type: 'string',
11+
describe: 'Name of your new Diffgram action'
12+
})
13+
}, create_action)
14+
.help(true)
15+
.argv;

bin/snippets/NewAction.py.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from eventhandlers.action_runners.base.ActionRunner import ActionRunner
2+
from eventhandlers.action_runners.base.ActionTrigger import ActionTrigger
3+
from eventhandlers.action_runners.base.ActionCondition import ActionCondition
4+
from eventhandlers.action_runners.base.ActionCompleteCondition import ActionCompleteCondition
5+
6+
7+
class NewNameAction(ActionRunner):
8+
public_name = 'NewName'
9+
icon = 'https://www.svgrepo.com/show/46774/export.svg'
10+
kind = 'NewName' # The kind has to be unique to all actions
11+
category = 'some_category' # Optional
12+
13+
# What events can this action listen to?
14+
trigger = ActionTrigger(default_event = 'some_diffgram_event',
15+
event_list = ['some_diffgram_event'])
16+
17+
# What pre-conditions can this action have?
18+
condition_data = ActionCondition(default_event = 'some_diffgram_event',
19+
event_list = ['some_diffgram_event'])
20+
21+
# How to declare the actions as completed?
22+
completion_condition_data = ActionCompleteCondition(default_event = 'some_diffgram_event',
23+
event_list = ['some_diffgram_event'])
24+
25+
def execute_pre_conditions(self, session) -> bool:
26+
# Return true if no pre-conditions are needed.
27+
return True
28+
29+
def execute_action(self, session):
30+
# Your core Action logic will go here.
31+
pass

bin/utils/action.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const fs = require("fs");
2+
const replacer = new RegExp('NewName', 'g')
3+
4+
function action({ NewActionName }) {
5+
const buffer = fs.readFileSync("./bin/snippets/NewAction.py.txt");
6+
const template = buffer.toString()
7+
const newAction = template.replace(replacer, NewActionName)
8+
}
9+
10+
module.exports = action;

package-lock.json

Lines changed: 121 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "diffgram-cli",
3+
"version": "0.0.0",
4+
"description": "Command line interface for Diffgram developers",
5+
"main": "bin/index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"bin": {
10+
"diffgram": "./bin/index.js"
11+
},
12+
"keywords": [
13+
"cli",
14+
"diffgram",
15+
"devtools"
16+
],
17+
"author": "Diffgram",
18+
"license": "ISC",
19+
"dependencies": {
20+
"yargs": "^17.5.1"
21+
}
22+
}

0 commit comments

Comments
 (0)