Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ All notable changes to the "vscode-ipaddress" extension will be documented in th

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.


## [1.0.1]
- Add `ipAddress.getSelectedIPAddress` command which allows to return the selected ip address as input variables in tasks.json or launch.json file

## [Unreleased]
- Initial release
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ You can also modify keyboard shortcut with JSON below.
}
```

You can alsoe insert the selected IP address into a configuration from `launch.json` or `tasks.json` using [input variables](https://code.visualstudio.com/docs/editor/variables-reference#_input-variables). For instance here for a `tasks.json` echoing the selection in the terminal:
```json
{
"version": "2.0.0",
"tasks": [
{
"label": "echo selected host ip",
"type": "shell",
"command": "echo 'selected host ip ${input:hostIP}'"
},
],
"inputs": [
{
"type": "command",
"id": "hostIP",
"command": "ipAddress.getSelectedIPAddress"
}
]
}
```

### Public IP address

Public IP address is obtained from OpenDNS via [`check-ip`](https://www.npmjs.com/package/public-ip) and updated every minute.
Expand Down
3 changes: 2 additions & 1 deletion commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ const PREFIX = 'ipAddress.';

module.exports = {
INSERT_IP_ADDRESS : PREFIX + 'insertIPAddress',
SHOW_NEXT_IP_ADDRESS: PREFIX + 'showNextIPAddress'
SHOW_NEXT_IP_ADDRESS: PREFIX + 'showNextIPAddress',
GET_SELECTED_IP_ADDRESS: PREFIX + 'getSelectedIPAddress'
};
6 changes: 6 additions & 0 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ function activate(context) {
statusBarItem.nextAddress();
})
);

context.subscriptions.push(
vscode.commands.registerCommand(Commands.GET_SELECTED_IP_ADDRESS, () => {
return statusBarItem.currentAddress();
})
);
}

exports.activate = activate;
Expand Down
12 changes: 12 additions & 0 deletions ipAddressStatusBarItem2.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ class IPAddressStatusBarItem {
nextAddress() {
this._interfaces.next();
}

currentAddress() {
const networkInterface = this._interfaces.current();

if (networkInterface) {
const address = networkInterface.get('address');
return address;
} else {
return null;
}


}

module.exports = IPAddressStatusBarItem;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-ipaddress",
"displayName": "IP Address",
"description": "Shows IP addresses in status bar and inserts into your text",
"version": "1.0.0",
"version": "1.0.1",
"publisher": "Compulim",
"engines": {
"vscode": "^1.11.0"
Expand Down