Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Command completions #7

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
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
143 changes: 143 additions & 0 deletions src/apex/cmds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
PrUn Palette - A command pallet for Prosperous Universe
Copyright (C) 2023 Stian Myklebostad

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

*/
import Apex from "./base";
import { GConstructor } from 'mixin'

const cmdsWithArgs = [
['ADM', 'Planet Identifier', ''],
['ADMT', 'Planet Identifier, Term identifier', ''],
['APEXM', '', ''],
['BBC', 'Base', ''],
['BBL', 'Base', ''],
['BDGS', '', ''],
['BLU', '', 'Blueprint'],
['BRA', '', ''],
['BS', '', 'Base'],
['BSC', 'Planet id', ''],
['BTF', 'Blueprint', ''],
['BUI', 'Building ticker', ''],
['CMDS', '', ''],
['CO', 'Company Code or ID', ''],
['COGC', 'Planet', ''],
['COGCPD', 'Planet, Program name', ''],
['COGCPEX', 'Planet', ''],
['COGCU', 'Planet', ''],
['COLIQ', '', ''],
['COM', '', ''],
['COMC', '', ''],
['COMF', '', ''],
['COMG', 'Channel Identifier', ''],
['COMP', 'Channel Identifier', ''],
['COMU', 'Username', ''],
['CONS', '', ''],
['CONT', 'Contract', ''],
['CONTD', '', 'Draft'],
['CONTS', '', ''],
['CORP', '', ''],
['CORPFIN', '', ''],
['CORPIVS', '', 'Company Code'],
['CORPNP', '', ''],
['CORPP', '', 'Project id'],
['CORPS', '', 'Corporation Code'],
['CS', '', ''],
['CX', 'Market Identifier Code', ''],
['CXL', '', ''],
['CXM', 'Material ticker', 'Planet to determine distance from'],
['CXO', 'Order ID', ''],
['CXOB', 'Ticker', ''],
['CXOS', '', ''],
['CXP', 'Ticker', ''],
['CXPC', 'Ticker', ''],
['CXPO', 'Ticker', ''],
['EXP', 'Base', ''],
['FA', 'Faction code', ''],
['FIN', '', ''],
['FINBS', '', ''],
['FINIS', '', ''],
['FINLA', '', ''],
['FLT', '', 'Address'],
['FLTP', 'Planet ID', ''],
['FLTS', 'System ID', ''],
['FX', '', ''],
['FXO', 'Order ID', ''],
['FXOB', 'Ticker', ''],
['FXOS', '', ''],
['FXP', 'FX ticker', ''],
['FXPC', 'FX ticker', ''],
['FXPO', 'FX ticker', ''],
['HELP', '', ''],
['HQ', '', ''],
['INF', '', 'System'],
['INV', '', 'Inventory'],
['LIC', '', ''],
['LM', 'Local Market Identifier', ''],
['LMA', 'Local Market Ad Identifier', ''],
['LMBL', '', ''],
['LMOS', '', ''],
['LMP', 'Local Market Identifier', ''],
['LR', 'Planet Identifier', ''],
['MAT', 'Material ticker', ''],
['MS', 'System', ''],
['MTRA', '', 'Material ticker, Origin store ID, Target store ID'],
['MU', '', 'Mode'],
['NOTIG', '', ''],
['NOTPNS', '', ''],
['NOTS', '', ''],
['PLI', '', 'Planet'],
['PLNM', 'Catalog ID', ''],
['POPI', 'Planet', ''],
['POPID', 'Planet, Infrastructure type', ''],
['POPR', '', 'Planet'],
['PP', 'Planet, Planetary project', ''],
['PPS', 'Planet', ''],
['PROD', '', 'Base'],
['PRODCO', 'Production line', ''],
['PRODQ', 'Production line', ''],
['PSI', 'Site', ''],
['RSB', '', ''],
['SFC', 'Ship', ''],
['SHP', 'Transponder', ''],
['SHPF', 'Transponder', ''],
['SHPI', 'Transponder', ''],
['SHY', '', 'Location Identifier'],
['SHYP', '', 'Shipyard Project Identifier'],
['SI', 'Transponder', ''],
['STNS', '', 'Station identifier'],
['SYSI', '', 'System'],
['SYSNM', 'Catalog ID', ''],
['TRA', '', ''],
['USR', 'Username', ''],
['WAR', 'Warehouse Identifier', ''],
['WF', 'Base', ''],
]
const cmds = cmdsWithArgs.map((cmd) => cmd[0])

console.debug('[PrUn Palette] Loaded cmds.ts', cmds)

export type Cmds = GConstructor<{
get Cmds(): string[]
}>

export function Cmds<TBase extends GConstructor<Apex>>(Base: TBase) {
return class Cmds extends Base {
public get Cmds(): string[] {
return cmds
}
}
}
6 changes: 4 additions & 2 deletions src/apex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import { Screen } from './screen'
import { Ships } from './ships'
import { Station } from './station'
import { Notification } from './notifications'
import { Cmds } from './cmds'

export default class Apex extends Notification (
export default class Apex extends Cmds (
Notification (
Station (
Screen (
FIO (
Expand All @@ -36,5 +38,5 @@ export default class Apex extends Notification (
Buffer (
Util (
Events (
ApexBase )))))))))
ApexBase ))))))))))
{}
3 changes: 3 additions & 0 deletions src/palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default class Palette {

private isFuzzable(sigPart: string | PaletteCommandVariables): boolean {
const fuzzableVariables = [
PaletteCommandVariables.Command,
PaletteCommandVariables.SystemName,
PaletteCommandVariables.SystemId,
PaletteCommandVariables.PlanetName,
Expand Down Expand Up @@ -197,6 +198,8 @@ export default class Palette {
const nextArg = command.signature[partialSig.length]
if (!isPaletteCommandVariable(nextArg)) return nextArg
switch (nextArg) {
case PaletteCommandVariables.Command:
return this.apex.Cmds.map(c => c.toLowerCase())
case PaletteCommandVariables.Screen:
return this.apex.Screens.map(s => s.name.toLowerCase())
case PaletteCommandVariables.SystemName:
Expand Down