-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
stop
command, add session management
- Loading branch information
Showing
9 changed files
with
158 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,46 @@ | ||
import * as vscode from 'vscode' | ||
import * as argon from '../argon' | ||
import { Item } from '.' | ||
import { State } from '../state' | ||
|
||
export const item: Item = { | ||
label: '$(stop) Stop', | ||
description: 'Stop running Argon instances', | ||
action: 'stop', | ||
} | ||
|
||
export function handler() {} | ||
export function handler(state: State) { | ||
let items = state.getSessions().map((session) => { | ||
return { label: session.project, id: session.id } | ||
}) | ||
|
||
if (items.length === 0) { | ||
return vscode.window.showQuickPick([], { | ||
title: 'No sessions to stop', | ||
}) | ||
} | ||
|
||
items.push({ label: '$(x)Stop all', id: 0 }) | ||
|
||
vscode.window | ||
.showQuickPick(items, { | ||
title: 'Select a session to stop', | ||
}) | ||
.then((item) => { | ||
if (!item) { | ||
return | ||
} | ||
|
||
if (item.id === 0) { | ||
items.forEach((item) => { | ||
if (item.id !== 0) { | ||
state.removeSession(item.id) | ||
argon.stop(item.id) | ||
} | ||
}) | ||
} else { | ||
state.removeSession(item.id) | ||
argon.stop(item.id) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
export interface Session { | ||
name: string | ||
project: string | ||
started: number | ||
export class Session { | ||
private started = Date.now() | ||
|
||
public name: string | ||
public project: string | ||
public id: number | ||
public address: string | undefined | ||
|
||
public constructor(name: string, project: string, id: number) { | ||
this.name = name | ||
this.project = project | ||
this.id = id | ||
} | ||
|
||
public withAddress(address: string) { | ||
this.address = address | ||
return this | ||
} | ||
|
||
public get duration() { | ||
return Date.now() - this.started | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters