Microsoft.Extensions.Configuration.CommandLine.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?xml version="1.0"?>
  2. <doc>
  3. <assembly>
  4. <name>Microsoft.Extensions.Configuration.CommandLine</name>
  5. </assembly>
  6. <members>
  7. <member name="T:Microsoft.Extensions.Configuration.CommandLineConfigurationExtensions">
  8. <summary>
  9. Extension methods for registering <see cref="T:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider"/> with <see cref="T:Microsoft.Extensions.Configuration.IConfigurationBuilder"/>.
  10. </summary>
  11. </member>
  12. <member name="M:Microsoft.Extensions.Configuration.CommandLineConfigurationExtensions.AddCommandLine(Microsoft.Extensions.Configuration.IConfigurationBuilder,System.String[])">
  13. <summary>
  14. Adds a <see cref="T:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider"/> <see cref="T:Microsoft.Extensions.Configuration.IConfigurationProvider"/>
  15. that reads configuration values from the command line.
  16. </summary>
  17. <param name="configurationBuilder">The <see cref="T:Microsoft.Extensions.Configuration.IConfigurationBuilder"/> to add to.</param>
  18. <param name="args">The command line args.</param>
  19. <returns>The <see cref="T:Microsoft.Extensions.Configuration.IConfigurationBuilder"/>.</returns>
  20. <remarks>
  21. <para>
  22. The values passed on the command line, in the <c>args</c> string array, should be a set
  23. of keys prefixed with two dashes ("--") and then values, separate by either the
  24. equals sign ("=") or a space (" ").
  25. </para>
  26. <para>
  27. A forward slash ("/") can be used as an alternative prefix, with either equals or space, and when using
  28. an equals sign the prefix can be left out altogether.
  29. </para>
  30. <para>
  31. There are five basic alternative formats for arguments:
  32. <c>key1=value1 --key2=value2 /key3=value3 --key4 value4 /key5 value5</c>.
  33. </para>
  34. </remarks>
  35. <example>
  36. A simple console application that has five values.
  37. <code>
  38. // dotnet run key1=value1 --key2=value2 /key3=value3 --key4 value4 /key5 value5
  39. using Microsoft.Extensions.Configuration;
  40. using System;
  41. namespace CommandLineSample
  42. {
  43. public class Program
  44. {
  45. public static void Main(string[] args)
  46. {
  47. var builder = new ConfigurationBuilder();
  48. builder.AddCommandLine(args);
  49. var config = builder.Build();
  50. Console.WriteLine($"Key1: '{config["Key1"]}'");
  51. Console.WriteLine($"Key2: '{config["Key2"]}'");
  52. Console.WriteLine($"Key3: '{config["Key3"]}'");
  53. Console.WriteLine($"Key4: '{config["Key4"]}'");
  54. Console.WriteLine($"Key5: '{config["Key5"]}'");
  55. }
  56. }
  57. }
  58. </code>
  59. </example>
  60. </member>
  61. <member name="M:Microsoft.Extensions.Configuration.CommandLineConfigurationExtensions.AddCommandLine(Microsoft.Extensions.Configuration.IConfigurationBuilder,System.String[],System.Collections.Generic.IDictionary{System.String,System.String})">
  62. <summary>
  63. Adds a <see cref="T:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider"/> <see cref="T:Microsoft.Extensions.Configuration.IConfigurationProvider"/> that reads
  64. configuration values from the command line using the specified switch mappings.
  65. </summary>
  66. <param name="configurationBuilder">The <see cref="T:Microsoft.Extensions.Configuration.IConfigurationBuilder"/> to add to.</param>
  67. <param name="args">The command line args.</param>
  68. <param name="switchMappings">
  69. The switch mappings. A dictionary of short (with prefix "-") and
  70. alias keys (with prefix "--"), mapped to the configuration key (no prefix).
  71. </param>
  72. <returns>The <see cref="T:Microsoft.Extensions.Configuration.IConfigurationBuilder"/>.</returns>
  73. <remarks>
  74. <para>
  75. The <c>switchMappings</c> allows additional formats for alternative short and alias keys
  76. to be used from the command line. Also see the basic version of <c>AddCommandLine</c> for
  77. the standard formats supported.
  78. </para>
  79. <para>
  80. Short keys start with a single dash ("-") and are mapped to the main key name (without
  81. prefix), and can be used with either equals or space. The single dash mappings are intended
  82. to be used for shorter alternative switches.
  83. </para>
  84. <para>
  85. Note that a single dash switch cannot be accessed directly, but must have a switch mapping
  86. defined and accessed using the full key. Passing an undefined single dash argument will
  87. cause as <c>FormatException</c>.
  88. </para>
  89. <para>
  90. There are two formats for short arguments:
  91. <c>-k1=value1 -k2 value2</c>.
  92. </para>
  93. <para>
  94. Alias key definitions start with two dashes ("--") and are mapped to the main key name (without
  95. prefix), and can be used in place of the normal key. They also work when a forward slash prefix
  96. is used in the command line (but not with the no prefix equals format).
  97. </para>
  98. <para>
  99. There are only four formats for aliased arguments:
  100. <c>--alt3=value3 /alt4=value4 --alt5 value5 /alt6 value6</c>.
  101. </para>
  102. </remarks>
  103. <example>
  104. A simple console application that has two short and four alias switch mappings defined.
  105. <code>
  106. // dotnet run -k1=value1 -k2 value2 --alt3=value2 /alt4=value3 --alt5 value5 /alt6 value6
  107. using Microsoft.Extensions.Configuration;
  108. using System;
  109. using System.Collections.Generic;
  110. namespace CommandLineSample
  111. {
  112. public class Program
  113. {
  114. public static void Main(string[] args)
  115. {
  116. var switchMappings = new Dictionary&lt;string, string&gt;()
  117. {
  118. { "-k1", "key1" },
  119. { "-k2", "key2" },
  120. { "--alt3", "key3" },
  121. { "--alt4", "key4" },
  122. { "--alt5", "key5" },
  123. { "--alt6", "key6" },
  124. };
  125. var builder = new ConfigurationBuilder();
  126. builder.AddCommandLine(args, switchMappings);
  127. var config = builder.Build();
  128. Console.WriteLine($"Key1: '{config["Key1"]}'");
  129. Console.WriteLine($"Key2: '{config["Key2"]}'");
  130. Console.WriteLine($"Key3: '{config["Key3"]}'");
  131. Console.WriteLine($"Key4: '{config["Key4"]}'");
  132. Console.WriteLine($"Key5: '{config["Key5"]}'");
  133. Console.WriteLine($"Key6: '{config["Key6"]}'");
  134. }
  135. }
  136. }
  137. </code>
  138. </example>
  139. </member>
  140. <member name="M:Microsoft.Extensions.Configuration.CommandLineConfigurationExtensions.AddCommandLine(Microsoft.Extensions.Configuration.IConfigurationBuilder,System.Action{Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationSource})">
  141. <summary>
  142. Adds an <see cref="T:Microsoft.Extensions.Configuration.IConfigurationProvider"/> that reads configuration values from the command line.
  143. </summary>
  144. <param name="builder">The <see cref="T:Microsoft.Extensions.Configuration.IConfigurationBuilder"/> to add to.</param>
  145. <param name="configureSource">Configures the source.</param>
  146. <returns>The <see cref="T:Microsoft.Extensions.Configuration.IConfigurationBuilder"/>.</returns>
  147. </member>
  148. <member name="T:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider">
  149. <summary>
  150. A command line based <see cref="T:Microsoft.Extensions.Configuration.ConfigurationProvider"/>.
  151. </summary>
  152. </member>
  153. <member name="M:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider.#ctor(System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IDictionary{System.String,System.String})">
  154. <summary>
  155. Initializes a new instance.
  156. </summary>
  157. <param name="args">The command line args.</param>
  158. <param name="switchMappings">The switch mappings.</param>
  159. </member>
  160. <member name="P:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider.Args">
  161. <summary>
  162. The command line arguments.
  163. </summary>
  164. </member>
  165. <member name="M:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider.Load">
  166. <summary>
  167. Loads the configuration data from the command line args.
  168. </summary>
  169. </member>
  170. <member name="T:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationSource">
  171. <summary>
  172. Represents command line arguments as an <see cref="T:Microsoft.Extensions.Configuration.IConfigurationSource"/>.
  173. </summary>
  174. </member>
  175. <member name="P:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationSource.SwitchMappings">
  176. <summary>
  177. Gets or sets the switch mappings.
  178. </summary>
  179. </member>
  180. <member name="P:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationSource.Args">
  181. <summary>
  182. Gets or sets the command line args.
  183. </summary>
  184. </member>
  185. <member name="M:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationSource.Build(Microsoft.Extensions.Configuration.IConfigurationBuilder)">
  186. <summary>
  187. Builds the <see cref="T:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider"/> for this source.
  188. </summary>
  189. <param name="builder">The <see cref="T:Microsoft.Extensions.Configuration.IConfigurationBuilder"/>.</param>
  190. <returns>A <see cref="T:Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider"/></returns>
  191. </member>
  192. <member name="P:System.SR.Error_DuplicatedKeyInSwitchMappings">
  193. <summary>Keys in switch mappings are case-insensitive. A duplicated key '{0}' was found.</summary>
  194. </member>
  195. <member name="P:System.SR.Error_InvalidSwitchMapping">
  196. <summary>The switch mappings contain an invalid switch '{0}'.</summary>
  197. </member>
  198. <member name="P:System.SR.Error_ShortSwitchNotDefined">
  199. <summary>The short switch '{0}' is not defined in the switch mappings.</summary>
  200. </member>
  201. </members>
  202. </doc>