{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Docs/issues/1382","repository_url":"https://api.github.com/repos/aspnet/Docs","labels_url":"https://api.github.com/repos/aspnet/Docs/issues/1382/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Docs/issues/1382/comments","events_url":"https://api.github.com/repos/aspnet/Docs/issues/1382/events","html_url":"https://github.com/aspnet/Docs/issues/1382","id":160058159,"number":1382,"title":"Configuration: Document format supported for command line arguments provider","user":{"login":"divega","id":1253414,"avatar_url":"https://avatars.githubusercontent.com/u/1253414?v=3","gravatar_id":"","url":"https://api.github.com/users/divega","html_url":"https://github.com/divega","followers_url":"https://api.github.com/users/divega/followers","following_url":"https://api.github.com/users/divega/following{/other_user}","gists_url":"https://api.github.com/users/divega/gists{/gist_id}","starred_url":"https://api.github.com/users/divega/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/divega/subscriptions","organizations_url":"https://api.github.com/users/divega/orgs","repos_url":"https://api.github.com/users/divega/repos","events_url":"https://api.github.com/users/divega/events{/privacy}","received_events_url":"https://api.github.com/users/divega/received_events","type":"User","site_admin":false},"labels":[{"id":197370485,"url":"https://api.github.com/repos/aspnet/Docs/labels/0%20-%20Backlog","name":"0 - Backlog","color":"CCCCCC","default":false},{"id":159095404,"url":"https://api.github.com/repos/aspnet/Docs/labels/bug","name":"bug","color":"fc2929","default":true},{"id":327110004,"url":"https://api.github.com/repos/aspnet/Docs/labels/P2","name":"P2","color":"009800","default":false}],"state":"open","locked":false,"assignee":{"login":"shirhatti","id":4734691,"avatar_url":"https://avatars.githubusercontent.com/u/4734691?v=3","gravatar_id":"","url":"https://api.github.com/users/shirhatti","html_url":"https://github.com/shirhatti","followers_url":"https://api.github.com/users/shirhatti/followers","following_url":"https://api.github.com/users/shirhatti/following{/other_user}","gists_url":"https://api.github.com/users/shirhatti/gists{/gist_id}","starred_url":"https://api.github.com/users/shirhatti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shirhatti/subscriptions","organizations_url":"https://api.github.com/users/shirhatti/orgs","repos_url":"https://api.github.com/users/shirhatti/repos","events_url":"https://api.github.com/users/shirhatti/events{/privacy}","received_events_url":"https://api.github.com/users/shirhatti/received_events","type":"User","site_admin":false},"assignees":[{"login":"shirhatti","id":4734691,"avatar_url":"https://avatars.githubusercontent.com/u/4734691?v=3","gravatar_id":"","url":"https://api.github.com/users/shirhatti","html_url":"https://github.com/shirhatti","followers_url":"https://api.github.com/users/shirhatti/followers","following_url":"https://api.github.com/users/shirhatti/following{/other_user}","gists_url":"https://api.github.com/users/shirhatti/gists{/gist_id}","starred_url":"https://api.github.com/users/shirhatti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shirhatti/subscriptions","organizations_url":"https://api.github.com/users/shirhatti/orgs","repos_url":"https://api.github.com/users/shirhatti/repos","events_url":"https://api.github.com/users/shirhatti/events{/privacy}","received_events_url":"https://api.github.com/users/shirhatti/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/aspnet/Docs/milestones/4","html_url":"https://github.com/aspnet/Docs/milestone/4","labels_url":"https://api.github.com/repos/aspnet/Docs/milestones/4/labels","id":1356168,"number":4,"title":"Backlog","description":"","creator":{"login":"danroth27","id":1874516,"avatar_url":"https://avatars.githubusercontent.com/u/1874516?v=3","gravatar_id":"","url":"https://api.github.com/users/danroth27","html_url":"https://github.com/danroth27","followers_url":"https://api.github.com/users/danroth27/followers","following_url":"https://api.github.com/users/danroth27/following{/other_user}","gists_url":"https://api.github.com/users/danroth27/gists{/gist_id}","starred_url":"https://api.github.com/users/danroth27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danroth27/subscriptions","organizations_url":"https://api.github.com/users/danroth27/orgs","repos_url":"https://api.github.com/users/danroth27/repos","events_url":"https://api.github.com/users/danroth27/events{/privacy}","received_events_url":"https://api.github.com/users/danroth27/received_events","type":"User","site_admin":false},"open_issues":179,"closed_issues":0,"state":"open","created_at":"2015-10-14T20:43:26Z","updated_at":"2016-12-13T02:18:31Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-06-13T22:22:14Z","updated_at":"2016-12-14T22:40:40Z","closed_at":null,"body":"Originally mentioned in https://github.com/aspnet/Configuration/issues/120:\n\n> ... it is not obvious, without looking at the code, how are they supposed to be used.\n> \n> For example, is I have:\n> \n> ``` C#\n> Configuration config = new Configuration();\n> config.AddCommandLine(args);\n> ```\n> \n> What is the format accepted by the strings in \"args\" to be valid? There are many possible options: `/key value`, `--key value`, `--key:value`, `key=value`, etc.\n\nFor some initial context, by default the command line arguments provider supports converting arguments of the format `key1=value1 key2=value2 key3=value3` Additional syntax with `-key1 value1`, `--key2 value2` and `/key3 value3` are supported when providing switch mappings.\n"},"comment":{"url":"https://api.github.com/repos/aspnet/Docs/issues/comments/267179790","html_url":"https://github.com/aspnet/Docs/issues/1382#issuecomment-267179790","issue_url":"https://api.github.com/repos/aspnet/Docs/issues/1382","id":267179790,"user":{"login":"spboyer","id":7681382,"avatar_url":"https://avatars.githubusercontent.com/u/7681382?v=3","gravatar_id":"","url":"https://api.github.com/users/spboyer","html_url":"https://github.com/spboyer","followers_url":"https://api.github.com/users/spboyer/followers","following_url":"https://api.github.com/users/spboyer/following{/other_user}","gists_url":"https://api.github.com/users/spboyer/gists{/gist_id}","starred_url":"https://api.github.com/users/spboyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spboyer/subscriptions","organizations_url":"https://api.github.com/users/spboyer/orgs","repos_url":"https://api.github.com/users/spboyer/repos","events_url":"https://api.github.com/users/spboyer/events{/privacy}","received_events_url":"https://api.github.com/users/spboyer/received_events","type":"User","site_admin":false},"created_at":"2016-12-14T22:40:40Z","updated_at":"2016-12-14T22:40:40Z","body":"The implementation of the CommandLine arguments are for settings similar to the Configuration providers that exist for INI,JSON, and XML files.  The difference here is the setting are passed in at start of the application conversely the files are used in the Startup.cs class.\r\n\r\n### Using a file\r\n```\r\npublic Startup(IHostingEnvironment env)\r\n{\r\n\tvar builder = new ConfigurationBuilder()\r\n\t\t.SetBasePath(env.ContentRootPath)\r\n\t\t.AddJsonFile(\"appsettings.json\", optional: true, reloadOnChange: true)\r\n\t\t.AddJsonFile($\"appsettings.{env.EnvironmentName}.json\", optional: true)\r\n\t\t.AddEnvironmentVariables();\r\n\tConfiguration = builder.Build();\r\n}\r\n```\r\n\r\n### Using command line provider\r\n\r\n```\r\ndotnet run --Key2=Value2 /Key3=Value3 -Key1=Value1\r\n\r\n# in Startup.cs\r\npublic Startup(IHostingEnvironment env)\r\n{\r\n\tvar builder = new ConfigurationBuilder()\r\n\t\t.SetBasePath(env.ContentRootPath)\r\n\t\t.AddCommandLine(args);\r\n\tConfiguration = builder.Build();\r\n}\r\n```\r\n\r\nThe port(s) that kestrel runs on are now configured using the `.UseUrls(string[])` method of WebHostBuilder\r\n\r\n```\r\npublic static void Main(string[] args)\r\n        {\r\n            var host = new WebHostBuilder()\r\n                .UseKestrel()\r\n                .UseUrls([\"http://*:5001\",\"http://*:5002\"])\r\n                .UseContentRoot(Directory.GetCurrentDirectory())\r\n                .UseIISIntegration()\r\n                .UseStartup<Startup>()\r\n                .Build();\r\n\r\n            host.Run();\r\n        }\r\n```\r\n"}}
{"actor":{"display_login":"spboyer"}}