Skip to content

Commit

Permalink
two commands added alongwith fix for the insiders input box
Browse files Browse the repository at this point in the history
  • Loading branch information
shanalikhan committed Jul 31, 2016
1 parent 70a4fed commit a25d11b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 27 deletions.
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "code-settings-sync",
"displayName": "Visual Studio Code Settings Sync",
"description": "Synchronize Settings, Snippets, launch, keybindings files and extensions Across Multiple Machines using Github GIST.",
"version": "1.5.0",
"version": "1.6.0",
"icon": "images/cloud.png",
"publisher": "Shan",
"author": {
Expand Down Expand Up @@ -31,12 +31,21 @@
"onCommand:extension.updateSettings",
"onCommand:extension.downloadSettings",
"onCommand:extension.resetSettings",
"onCommand:extension.releaseNotes"
"onCommand:extension.releaseNotes",
"onCommand:extension.openSettings",
"onCommand:extension.HowSettings"
],
"main": "./out/src/extension",
"contributes": {
"commands": [

{
"command": "extension.openSettings",
"title": "Sync : Open Settings"
},
{
"command": "extension.HowSettings",
"title": "Sync : How To Configure"
},
{
"command": "extension.downloadSettings",
"title": "Sync : Download Settings"
Expand Down
53 changes: 31 additions & 22 deletions src/commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,19 @@ export class Commons {
(function getToken() {
vscode.window.showInputBox(opt).then(async (token) => {
if (token && token.trim()) {
sett.Token = token.trim();
await me.SaveSettings(sett).then(function (saved: boolean) {
if (saved) {
vscode.window.setStatusBarMessage("Token Saved", 1000);
}
resolve(saved);
}, function (err: any) {
reject(err);
});
token = token.trim();

if (token != 'esc') {
sett.Token = token;
await me.SaveSettings(sett).then(function (saved: boolean) {
if (saved) {
vscode.window.setStatusBarMessage("Token Saved", 1000);
}
resolve(saved);
}, function (err: any) {
reject(err);
});
}
} else {
if (token !== 'esc') {
getToken()
Expand All @@ -110,22 +114,27 @@ export class Commons {
(function getGist() {
vscode.window.showInputBox(opt).then(async (gist) => {
if (gist && gist.trim()) {
sett.Gist = gist.trim();
await me.SaveSettings(sett).then(function (saved: boolean) {
if (saved) {
vscode.window.setStatusBarMessage("Gist Saved", 1000);
}
resolve(saved);
}, function (err: any) {
reject(err);
});
gist = gist.trim();
if (gist != 'esc') {
sett.Gist = gist.trim();
await me.SaveSettings(sett).then(function (saved: boolean) {
if (saved) {
vscode.window.setStatusBarMessage("Gist Saved", 1000);
}
resolve(saved);
}, function (err: any) {
reject(err);
});
}

} else {
if (gist !== 'esc') {
getGist()
getGist();
}
}

});
});
})();

});
}
Expand All @@ -137,15 +146,15 @@ export class Commons {
let options: vscode.InputBoxOptions = {
placeHolder: "Enter Github Personal Access Token",
password: false,
prompt: "Link is opened to get the github token. Enter token and press [Enter] or type 'esc' to cancel......................................................."
prompt: "Link is opened to get the github token. Enter token and press [Enter] or type 'esc' to cancel."
};
return options;
}
else {
let options: vscode.InputBoxOptions = {
placeHolder: "Enter GIST ID",
password: false,
prompt: "Enter GIST ID from previously uploaded settings and press [Enter] or type 'esc' to cancel................................................................."
prompt: "Enter GIST ID from previously uploaded settings and press [Enter] or type 'esc' to cancel."
};
return options;
}
Expand Down
27 changes: 27 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,5 +419,32 @@ export function activate(context: vscode.ExtensionContext) {
openurl("http://shanalikhan.github.io/2016/05/14/Visual-studio-code-sync-settings-release-notes.html");
});

var disposable = vscode.commands.registerCommand('extension.openSettings', async () => {

openurl("http://shanalikhan.github.io/2016/07/31/Visual-Studio-code-sync-setting-edit-manually.html");
vscode.window.showInformationMessage("If the extension is not setup then use How To Configure command to setup this extension.");

vscode.window.showInformationMessage("Read link is opened if you need help in editing the JSON File manually.");

var en: envir.Environment = new envir.Environment(context);
var fManager: fileManager.FileManager;
var common: commons.Commons = new commons.Commons(en);
var syncSetting: Setting = await common.InitSettings();


var setting : vscode.Uri = vscode.Uri.file(en.APP_SETTINGS);
vscode.workspace.openTextDocument(setting).then((a: vscode.TextDocument) => {
vscode.window.showTextDocument(a,1,false);
});


});

var disposable = vscode.commands.registerCommand('extension.HowSettings', async () => {
openurl("http://shanalikhan.github.io/2015/12/15/Visual-Studio-Code-Sync-Settings.html");
});



context.subscriptions.push(disposable);
}
2 changes: 0 additions & 2 deletions src/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
export class Setting{
public Token : string = null;
public Gist : string = null;
public ProxyIP : string = null;
public ProxyPort : string = null;
}

0 comments on commit a25d11b

Please sign in to comment.