forked from CodeWithSwastik/vscode.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages.py
38 lines (26 loc) · 1003 Bytes
/
messages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import vscode
ext = vscode.Extension(name="Messages")
@ext.command()
async def info(ctx):
vscode.window.show_info_message("This is an info message")
await ctx.show(vscode.InfoMessage("This is an info message"))
@ext.command()
async def warn(ctx):
vscode.window.show_warn_message("This is a warning message")
await ctx.show(vscode.WarningMessage("This is a warning message"))
@ext.command()
async def error(ctx):
vscode.window.show_error_message("This is an error message")
await ctx.show(vscode.ErrorMessage("This is an error message"))
@ext.command()
async def show_choices(ctx):
# This works the same with warning and error
message = vscode.InfoMessage("Are you happy using this?", ["Yes", "No"])
choice = await ctx.show(message)
if not choice:
return
elif choice == "Yes":
await ctx.show(vscode.InfoMessage("Thanks :)"))
else:
await ctx.show(vscode.InfoMessage(":("))
ext.run()