Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
B Language Extension
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
B Language Extension
Commits
c876966d
Commit
c876966d
authored
5 years ago
by
SeeBasTStick
Browse files
Options
Downloads
Patches
Plain Diff
added optionAddedScript
parent
97184a19
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.vscodeignore
+1
-0
1 addition, 0 deletions
.vscodeignore
optionAdder.py
+72
-0
72 additions, 0 deletions
optionAdder.py
with
73 additions
and
0 deletions
.vscodeignore
+
1
−
0
View file @
c876966d
...
@@ -2,4 +2,5 @@
...
@@ -2,4 +2,5 @@
.vscode-test/**
.vscode-test/**
.gitignore
.gitignore
media/**
media/**
optionAdder.py
vsc-extension-quickstart.md
vsc-extension-quickstart.md
This diff is collapsed.
Click to expand it.
optionAdder.py
0 → 100644
+
72
−
0
View file @
c876966d
import
json
import
sys
# Example: python3 optionAdder.py --add test '-p MEGATEST' 'A cool option' /home/sebastian/b-eventb-language-extension/
def
modify_server
(
varName
:
str
,
comand
:
str
,
filename
):
var_marker
:
str
=
'
//PYTHONVAR
'
if_marker
:
str
=
'
//PYTHONIF
'
setting_marker
:
str
=
'
//PYTHONSETTING
'
default_marker
:
str
=
'
//PYTHONDEFAULT
'
python_command
:
str
=
'
/*PYTHONCMD*/
'
with
open
(
filename
)
as
file
:
# Get only numbers
file_handler
=
file
.
readlines
()
new_file
=
[]
for
line
in
file_handler
:
if
setting_marker
in
line
:
new_file
.
append
(
'
\t
'
+
varName
+
'
:boolean
\n
'
)
if
default_marker
in
line
:
new_file
.
append
(
'
\t
'
+
varName
+
'
:false,
\n
'
)
if
var_marker
in
line
:
new_file
.
append
(
'
\t
let
'
+
varName
+
'
=
""
\n\t
'
)
if
if_marker
in
line
:
new_file
.
append
(
'
\n\t
if(settings.
'
+
varName
+
'
== true){
\n\t\t
'
+
varName
+
'
=
'
+
'
"'
+
comand
+
'"
'
+
'
\n
'
+
'
\t
}
\n
'
)
if
python_command
in
line
:
new_file
.
append
(
'
\t\t\t\t\t\t\t
+
'
+
varName
+
'
\n
'
)
new_file
.
append
(
line
)
with
open
(
filename
,
'
w
'
)
as
f
:
f
.
writelines
(
new_file
)
def
modify_package
(
varName
:
str
,
description
:
str
,
filename
:
str
):
with
open
(
filename
)
as
file
:
attribute_dict
=
{
'
scope
'
:
'
window
'
,
'
type
'
:
'
boolean
'
,
'
default
'
:
'
false
'
,
'
description
'
:
description
}
file_handler
=
json
.
load
(
file
)
file_handler
[
'
contributes
'
][
'
configuration
'
][
'
properties
'
][
'
languageServer.
'
+
varName
]
=
attribute_dict
json
.
dumps
(
file_handler
)
with
open
(
filename
,
'
w
'
)
as
f
:
json
.
dump
(
file_handler
,
f
,
indent
=
4
)
def
main
():
if
len
(
sys
.
argv
)
>=
2
:
if
sys
.
argv
[
1
]
==
'
--help
'
:
print
(
'
Helper to add boolean options quickly
'
)
print
(
'
Usage:
'
)
print
(
'
python --add optionName optionCommand optionDescription dirOfPackage.json
'
)
elif
sys
.
argv
[
1
]
==
'
--add
'
and
len
(
sys
.
argv
)
==
6
:
print
(
sys
.
argv
)
optionName
=
sys
.
argv
[
2
]
optionCommand
=
sys
.
argv
[
3
]
optionDescription
=
sys
.
argv
[
4
]
homeDir
=
sys
.
argv
[
5
]
modify_server
(
optionName
,
optionCommand
,
homeDir
+
'
/server/src/server.ts
'
)
modify_package
(
optionName
,
optionDescription
,
homeDir
+
'
/package.json
'
)
else
:
print
(
"
Something went wrong
"
)
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment