mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-09 23:37:54 +00:00
feat: implement system name etc. commands
This commit is contained in:
parent
87f6fe9d75
commit
ac52b5c257
10 changed files with 155 additions and 103 deletions
|
|
@ -149,10 +149,11 @@ public class Context
|
|||
public LookupContext DirectLookupContextFor(SystemId systemId)
|
||||
=> System?.Id == systemId ? LookupContext.ByOwner : LookupContext.ByNonOwner;
|
||||
|
||||
public LookupContext LookupContextFor(SystemId systemId)
|
||||
public LookupContext LookupContextFor(SystemId systemId, bool? _hasPrivateOverride = null, bool? _hasPublicOverride = null)
|
||||
{
|
||||
var hasPrivateOverride = Parameters.HasFlag("private", "priv");
|
||||
var hasPublicOverride = Parameters.HasFlag("public", "pub");
|
||||
// TODO(yusdacra): these should be passed as a parameter to this method all the way from command tree
|
||||
bool hasPrivateOverride = _hasPrivateOverride ?? Parameters.HasFlag("private", "priv");
|
||||
bool hasPublicOverride = _hasPublicOverride ?? Parameters.HasFlag("public", "pub");
|
||||
|
||||
if (hasPrivateOverride && hasPublicOverride)
|
||||
throw new PKError("Cannot match both public and private flags at the same time.");
|
||||
|
|
|
|||
|
|
@ -111,8 +111,7 @@ public class Parameters
|
|||
// todo: i think this should return null for everything...?
|
||||
if (param == null) return default;
|
||||
return extract_func(param)
|
||||
// this should never really happen (hopefully!), but in case the parameter names dont match up (typos...) between rust <-> c#...
|
||||
// (it would be very cool to have this statically checked somehow..?)
|
||||
// this should never happen unless codegen somehow uses a wrong name
|
||||
?? throw new PKError($"Flag {flag_name.AsCode()} was not found or did not have a value defined for command {Callback().AsCode()} -- this is a bug!!");
|
||||
}
|
||||
|
||||
|
|
@ -122,8 +121,7 @@ public class Parameters
|
|||
// todo: i think this should return null for everything...?
|
||||
if (param == null) return default;
|
||||
return extract_func(param)
|
||||
// this should never really happen (hopefully!), but in case the parameter names dont match up (typos...) between rust <-> c#...
|
||||
// (it would be very cool to have this statically checked somehow..?)
|
||||
// this should never happen unless codegen somehow uses a wrong name
|
||||
?? throw new PKError($"Parameter {param_name.AsCode()} was not found for command {Callback().AsCode()} -- this is a bug!!");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue