Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
koishi-decorators
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
koishi-decorators
Commits
e3c5da37
Commit
e3c5da37
authored
Mar 13, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow arg def in put param
parent
6419ff4b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
5 deletions
+16
-5
src/decorators/decorators.ts
src/decorators/decorators.ts
+2
-1
src/def/interfaces.ts
src/def/interfaces.ts
+5
-0
src/registry/registries/command-put.ts
src/registry/registries/command-put.ts
+8
-3
src/utility/native-type-mapping.ts
src/utility/native-type-mapping.ts
+1
-1
No files found.
src/decorators/decorators.ts
View file @
e3c5da37
...
...
@@ -184,7 +184,8 @@ export const PutArgv = (field?: keyof Argv) =>
field
?
CommandPut
.
decorate
(
'
argvField
'
,
field
)
:
CommandPut
.
decorate
(
'
argv
'
);
export
const
PutSession
=
(
field
?:
keyof
Session
)
=>
field
?
CommandPut
.
decorate
(
'
sessionField
'
,
field
)
:
PutArgv
(
'
session
'
);
export
const
PutArg
=
(
i
:
number
)
=>
CommandPut
.
decorate
(
'
arg
'
,
i
);
export
const
PutArg
=
(
index
:
number
,
decl
?:
Argv
.
Declaration
)
=>
CommandPut
.
decorate
(
'
arg
'
,
{
index
,
decl
});
export
const
PutArgs
=
()
=>
CommandPut
.
decorate
(
'
args
'
);
export
const
PutOption
=
(
name
:
string
,
...
...
src/def/interfaces.ts
View file @
e3c5da37
...
...
@@ -159,3 +159,8 @@ export interface CommandLocaleDef extends Store {
options
?:
Dict
<
string
>
;
messages
?:
Store
;
}
export
interface
CommandArgDef
{
index
:
number
;
decl
?:
Argv
.
Declaration
;
}
src/registry/registries/command-put.ts
View file @
e3c5da37
import
{
Argv
,
Command
,
Context
,
FieldCollector
,
Session
,
User
}
from
'
koishi
'
;
import
{
CommandArgDef
,
CommandOptionConfig
,
GenerateMappingStruct
,
KoishiCommandPutDef
,
...
...
@@ -17,7 +18,7 @@ import {
export
namespace
CommandPut
{
export
interface
ConfigMap
{
args
:
void
;
arg
:
number
;
arg
:
CommandArgDef
;
argv
:
void
;
argvField
:
keyof
Argv
;
option
:
CommandOptionConfig
;
...
...
@@ -45,9 +46,13 @@ export namespace CommandPut {
);
preRegistry
.
extend
(
'
arg
'
,
(
data
,
cmd
,
ctx
,
nativeType
)
=>
{
const
arg
=
cmd
.
_arguments
[
data
];
const
arg
=
cmd
.
_arguments
[
data
.
index
];
if
(
arg
)
{
applyNativeTypeToArg
(
arg
,
nativeType
);
}
else
if
(
data
.
decl
)
{
const
decl
=
{
...
data
.
decl
};
applyNativeTypeToArg
(
decl
,
nativeType
);
cmd
.
_arguments
[
data
.
index
]
=
decl
;
}
});
...
...
@@ -81,7 +86,7 @@ export namespace CommandPut {
>
();
registry
.
extend
(
'
args
'
,
(
data
,
argv
,
args
)
=>
args
);
registry
.
extend
(
'
arg
'
,
(
data
,
argv
,
args
)
=>
args
[
data
]);
registry
.
extend
(
'
arg
'
,
(
data
,
argv
,
args
)
=>
args
[
data
.
index
]);
registry
.
extend
(
'
argv
'
,
(
data
,
argv
,
args
)
=>
argv
);
registry
.
extend
(
'
argvField
'
,
(
data
,
argv
,
args
)
=>
argv
[
data
]);
registry
.
extend
(
'
option
'
,
(
data
,
argv
,
args
)
=>
argv
.
options
[
data
.
name
]);
...
...
src/utility/native-type-mapping.ts
View file @
e3c5da37
import
{
Argv
}
from
'
koishi
'
;
// eslint-disable-next-line @typescript-eslint/ban-types
const
nativeTypeMapping
=
new
Map
<
Function
,
Argv
.
Type
>
();
export
const
nativeTypeMapping
=
new
Map
<
Function
,
Argv
.
Type
>
();
nativeTypeMapping
.
set
(
String
,
'
string
'
);
nativeTypeMapping
.
set
(
Number
,
'
number
'
);
nativeTypeMapping
.
set
(
Boolean
,
'
boolean
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment