@@ -43,6 +43,7 @@ export type Metadata = {
43
43
44
44
type MetadataFlag = {
45
45
setFromDefault ?: boolean ;
46
+ defaultHelp ?: unknown ;
46
47
}
47
48
48
49
export type ListItem = [ string , string | undefined ]
@@ -55,11 +56,94 @@ export type DefaultContext<T> = {
55
56
flags : Record < string , string > ;
56
57
}
57
58
58
- export type FlagDefault < T , P = CustomOptions > = T | ( ( context : DefaultContext < P & OptionFlag < T , P > > ) => Promise < T > )
59
- export type FlagDefaultHelp < T , P = CustomOptions > = T | ( ( context : DefaultContext < P & OptionFlag < T , P > > ) => Promise < string | undefined > )
60
-
61
- export type ArgDefault < T , P = CustomOptions > = T | ( ( context : DefaultContext < Arg < T , P > > ) => Promise < T > )
62
- export type ArgDefaultHelp < T , P = CustomOptions > = T | ( ( context : DefaultContext < Arg < T , P > > ) => Promise < string | undefined > )
59
+ /**
60
+ * Type to define a default value for a flag.
61
+ * @param context The context of the flag.
62
+ * @param isWritingManifest Informs the function that a manifest file is being written.
63
+ * The manifest file is used to store the flag definitions, with a default value if present, for a command and is published to npm.
64
+ * When a manifest file is being written, the default value may contain data that should not be included in the manifest.
65
+ * The plugin developer can use isWritingManifest to determine if the default value should be omitted from the manifest.
66
+ * in the function's implementation.
67
+ * @example
68
+ * static flags = {
69
+ * foo: flags.string({
70
+ * defaultHelp: async (context, isWritingManifest) => {
71
+ * if (isWritingManifest) {
72
+ * return undefined
73
+ * }
74
+ * return 'value that is used outside a manifest'
75
+ * },
76
+ * }),
77
+ * }
78
+ */
79
+ export type FlagDefault < T , P = CustomOptions > = T | ( ( context : DefaultContext < P & OptionFlag < T , P > > , isWritingManifest ?: boolean ) => Promise < T > )
80
+
81
+ /**
82
+ * Type to define a defaultHelp value for a flag.
83
+ * The defaultHelp value is used in the help output for the flag and when writing a manifest.
84
+ * It is also can be used to provide a value for the flag when issuing certain error messages.
85
+ *
86
+ * @param context The context of the flag.
87
+ * @param isWritingManifest Informs the function that a manifest file is being written.
88
+ * The manifest file is used to store the flag definitions, with a default value if present via defaultHelp, for a command and is published to npm.
89
+ * When a manifest file is being written, the default value may contain data that should not be included in the manifest.
90
+ * The plugin developer can use isWritingManifest to determine if the defaultHelp value should be omitted from the manifest.
91
+ * in the function's implementation.
92
+ * @example
93
+ * static flags = {
94
+ * foo: flags.string({
95
+ * defaultHelp: async (context, isWritingManifest) => {
96
+ * if (isWritingManifest) {
97
+ * return undefined
98
+ * }
99
+ * return 'value that is used outside a manifest'
100
+ * },
101
+ * }),
102
+ * }
103
+ */
104
+ export type FlagDefaultHelp < T , P = CustomOptions > = T | ( ( context : DefaultContext < P & OptionFlag < T , P > > , isWritingManifest ?: boolean ) => Promise < string | undefined > )
105
+
106
+ /**
107
+ * Type to define a default value for an arg.
108
+ * @param context The context of the arg.
109
+ * @param isWritingManifest Informs the function that a manifest file is being written.
110
+ * The manifest file is used to store the arg definitions, with a default value if present, for a command and is published to npm.
111
+ * When a manifest file is being written, the default value may contain data that should not be included in the manifest.
112
+ * The plugin developer can use isWritingManifest to determine if the default value should be omitted from the manifest.
113
+ * in the function's implementation.
114
+ * @example
115
+ * public static readonly args = {
116
+ * one: Args.string({
117
+ * default: async (context, isWritingManifest) => {
118
+ * if (isWritingManifest) {
119
+ * return undefined
120
+ * }
121
+ * return 'value that is used outside a manifest'
122
+ * }),
123
+ * };
124
+ */
125
+ export type ArgDefault < T , P = CustomOptions > = T | ( ( context : DefaultContext < Arg < T , P > > , isWritingManifest ?: boolean ) => Promise < T > )
126
+
127
+ /**
128
+ * Type to define a defaultHelp value for an arg.
129
+ * @param context The context of the arg.
130
+ * @param isWritingManifest Informs the function that a manifest file is being written.
131
+ * The manifest file is used to store the arg definitions, with a default value if present via defaultHelp, for a command and is published to npm.
132
+ * When a manifest file is being written, the default value may contain data that should not be included in the manifest.
133
+ * The plugin developer can use isWritingManifest to determine if the default value should be omitted from the manifest.
134
+ * in the function's implementation.
135
+ * @example
136
+ * public static readonly args = {
137
+ * one: Args.string({
138
+ * defaultHelp: async (context, isWritingManifest) => {
139
+ * if (isWritingManifest) {
140
+ * return undefined
141
+ * }
142
+ * return 'value that is used outside a manifest'
143
+ * }),
144
+ * };
145
+ */
146
+ export type ArgDefaultHelp < T , P = CustomOptions > = T | ( ( context : DefaultContext < Arg < T , P > > , isWritingManifest ?: boolean ) => Promise < string | undefined > )
63
147
64
148
export type FlagRelationship = string | { name : string ; when : ( flags : Record < string , unknown > ) => Promise < boolean > } ;
65
149
export type Relationship = {
0 commit comments