Fixing a couple of bugs related to loading the configuration file. Added
settings to the package menu.
This commit is contained in:
parent
87cecce263
commit
3110bf6201
|
|
@ -0,0 +1,2 @@
|
|||
*.pyc
|
||||
package-metadata.json
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"cli_path": "C:\\Users\\seich\\AppData\\Roaming\\npm\\beau"
|
||||
// Beau's CLI Location
|
||||
"cli_path": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
Copyright 2017 David Diaz <seich@martianwabbit.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
[
|
||||
{
|
||||
"caption": "Preferences",
|
||||
"mnemonic": "n",
|
||||
"id": "preferences",
|
||||
"children": [
|
||||
{
|
||||
"caption": "Package Settings",
|
||||
"mnemonic": "P",
|
||||
"id": "package-settings",
|
||||
"children": [
|
||||
{
|
||||
"caption": "Beau",
|
||||
"children": [
|
||||
{
|
||||
"caption": "Settings – Default",
|
||||
"command": "open_file",
|
||||
"args": {
|
||||
"file": "${packages}/Beau/Beau.sublime-settings"
|
||||
}
|
||||
},
|
||||
{
|
||||
"caption": "Settings – User",
|
||||
"command": "open_file",
|
||||
"args": {
|
||||
"file": "${packages}/User/Beau.sublime-settings"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# Beau
|
||||
|
||||
## Description
|
||||
This plugin allows you to use beau on your beau files without having to leave sublime.
|
||||
|
||||
## Usage
|
||||
To trigger a beau request open your command palette (ctrl+shift+t or cmd+shift+p) and type `Beau Request`.
|
||||
Pressing enter will open a secondary menu that'll allow you to trigger a particular request in that file.
|
||||
A new Tab will open once the request is complete showing the result for that particular request.
|
||||
|
||||
## Setup
|
||||
Before usage you'll need to let sublime know where to find your beau executable.
|
||||
To do this, open the settings file by going to `Preferences > Package Settings > Beau > Settings - User`.
|
||||
In the open file specify the correct cli path in for the `cli_path` setting.
|
||||
|
||||
If you haven't installed beau yet, you can do it by using `npm install -g beau`
|
||||
30
beau.py
30
beau.py
|
|
@ -4,21 +4,20 @@ import sublime_plugin
|
|||
from http.client import responses
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
PLUGIN_NAME = 'Beau'
|
||||
SETTINGS_FILE = '{0}.sublime-settings'.format(PLUGIN_NAME)
|
||||
SETTINGS_FILE = 'Beau.sublime-settings'
|
||||
SYNTAX = 'Packages/JavaScript/JSON.sublime-syntax'
|
||||
settings = sublime.load_settings(SETTINGS_FILE)
|
||||
|
||||
class InsertTextCommand(sublime_plugin.TextCommand):
|
||||
def run(self, edit, text):
|
||||
self.view.insert(edit, 0, text)
|
||||
|
||||
|
||||
class BeauCommand(sublime_plugin.TextCommand):
|
||||
requests = []
|
||||
path = settings.get('cli_path', '')
|
||||
path = ''
|
||||
|
||||
def run(self, edit):
|
||||
settings = sublime.load_settings(SETTINGS_FILE)
|
||||
self.path = settings.get('cli_path', '')
|
||||
active_window = sublime.active_window()
|
||||
active_view = active_window.active_view()
|
||||
|
||||
|
|
@ -27,6 +26,14 @@ class BeauCommand(sublime_plugin.TextCommand):
|
|||
active_window.status_message('Beau can only be ran on yaml files.')
|
||||
return
|
||||
|
||||
print([
|
||||
settings,
|
||||
self.path,
|
||||
'-c',
|
||||
active_view.file_name(),
|
||||
'--clean-list'
|
||||
])
|
||||
|
||||
proc = Popen([
|
||||
self.path,
|
||||
'-c',
|
||||
|
|
@ -42,13 +49,24 @@ class BeauCommand(sublime_plugin.TextCommand):
|
|||
self.requests[:] = []
|
||||
for line in iter(proc.stdout.readline, b''):
|
||||
req = line.decode('utf-8').rstrip().split('\t')
|
||||
|
||||
if len(req) == 3:
|
||||
method, alias, endpoint = req
|
||||
requests.append([alias, endpoint])
|
||||
self.requests.append(req)
|
||||
|
||||
elif len(req) == 5:
|
||||
method, alias, endpoint, title, description = req
|
||||
self.requests.append([method, alias, endpoint])
|
||||
|
||||
if description == 'undefined':
|
||||
description = endpoint
|
||||
|
||||
if title == 'undefined':
|
||||
title = alias
|
||||
else:
|
||||
title = title + ' (' + alias + ')'
|
||||
|
||||
requests.append([title, description])
|
||||
|
||||
proc.wait()
|
||||
|
|
@ -91,7 +109,7 @@ class BeauCommand(sublime_plugin.TextCommand):
|
|||
content += status + ' ' + responses[int(status)] + '\n\n'
|
||||
content += 'Response Headers: \n'
|
||||
content += self.autoindent(headers)
|
||||
content += '\n\n Response Body: \n'
|
||||
content += '\n\nResponse Body: \n'
|
||||
content += self.autoindent(body)
|
||||
|
||||
results_view.run_command('insert_text', {'text': content})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"install": "mesages/install.txt"
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# Beau
|
||||
|
||||
## Installation
|
||||
Before beginning you need to have installed beau, you can find out how to
|
||||
do so here: https://github.com/seich/beau.
|
||||
|
||||
## Setup
|
||||
The first thing you should do now if open up the settings
|
||||
file (Preferences > Package Settings > Beau > Settings - User) and set up your cli_path.
|
||||
It should be pointing to the location of your beau installation.
|
||||
|
||||
## Usage
|
||||
Once that's done, you can start use beau without leaving sublime.
|
||||
To use this plugin, open up a beau config file and open the commands palette (ctrl + shift + p).
|
||||
Type Beau Request and select the request you want to make. A new file should open showing you the
|
||||
result of that request.
|
||||
Loading…
Reference in New Issue