{"id":18925175,"url":"https://github.com/b2r2-org/fsoptparse","last_synced_at":"2025-09-05T01:32:05.135Z","repository":{"id":23651936,"uuid":"27022481","full_name":"B2R2-org/FsOptParse","owner":"B2R2-org","description":"A single-file FSharp-based command line argument parsing","archived":false,"fork":false,"pushed_at":"2025-08-23T04:24:16.000Z","size":1574,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-23T09:57:58.523Z","etag":null,"topics":["dotnet-core","fsharp","optparse"],"latest_commit_sha":null,"homepage":null,"language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/B2R2-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-23T04:57:24.000Z","updated_at":"2025-08-23T04:24:03.000Z","dependencies_parsed_at":"2022-08-22T02:30:54.922Z","dependency_job_id":null,"html_url":"https://github.com/B2R2-org/FsOptParse","commit_stats":null,"previous_names":["sangkilc/optparse.fs"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/B2R2-org/FsOptParse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/B2R2-org%2FFsOptParse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/B2R2-org%2FFsOptParse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/B2R2-org%2FFsOptParse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/B2R2-org%2FFsOptParse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/B2R2-org","download_url":"https://codeload.github.com/B2R2-org/FsOptParse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/B2R2-org%2FFsOptParse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273699516,"owners_count":25152278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet-core","fsharp","optparse"],"created_at":"2024-11-08T11:09:51.151Z","updated_at":"2025-09-05T01:32:00.124Z","avatar_url":"https://github.com/B2R2-org.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"B2R2.FsOptParse: An F# Command Line Parsing Library\n===============================================\n\nB2R2.FsOptParse library (B2R2.FsOptParse.dll) implements command-line parsing\nAPIs that are succinct and clean. It is completely written in a single F# file\n(fs). It is very intuitive to use, and also provides lots of convenient\ncommand-line parsing features.\n\nB2R2.FsOptParse exposes just two functions including `optParse` and `usageExit`.\nThe `optParse` function takes in a specification of command line options, a\nprogram name, and a list of arguments from a user as input. It then parses the\ninput arguments and calls corresponding callback functions registered through\nthe specification as per interpreting each encountered option. Finally, it\nreturns a list of unmatched arguments. The `usageExit` function prints out a\nwell-formed usage based on a given specification, and terminates the program.\n\nBuild\n-----\nB2R2.FsOptParse relies on .NET Core. Simply type `dotnet build` in a terminal.\n\nPackage\n-------\nAvailable in NuGet.\n\n[![NuGet Status](http://img.shields.io/nuget/v/B2R2.FsOptParse.svg?style=flat)](https://www.nuget.org/packages/B2R2.FsOptParse/)\n\nExample\n-------\n\nThe src/OptTest.fsx file contains an example usage.\n\n\n```fsharp\nopen B2R2.FsOptParse\n\n(** defines a state to pass to the option parser *)\ntype opts =\n  {\n    optX : int;\n    optY : bool;\n    optZ : string;\n  }\n\n(** default option state *)\nlet defaultOpts =\n  {\n    optX = 0;\n    optY = false;\n    optZ = \"\";\n  }\n\n(*\n  An example command line specification, which is a list of Options.\n  Each Option describes a command line option (switch) that is specified with\n  either a short (a single-dash option) or long option (a double-dash option).\n*)\nlet spec =\n  [\n    (* This option can be specified with -x \u003cNUM\u003e. There is an extra argument to\n       specify a value in integer. *)\n    Option ((* description of the option *)\n            descr=\"this is a testing param X\",\n            (* how many extra argument must be provided by a user? *)\n            extra=1,\n            (* callback sets up the option and returns it *)\n            callback=(fun opts arg -\u003e {opts with optX=(int) arg.[0]}),\n            (* use a short option style -x *)\n            short=\"-x\"\n           );\n\n    (* This option can be specified with -y. There is no extra argument. This\n       option just sets a flag, optY. *)\n    Option ((* description of the option *)\n            descr=\"this is a testing param Y\",\n            (* set the option to be true *)\n            callback=(fun opts _ -\u003e {opts with optY=true}),\n            (* use a short option style (-y) *)\n            short=\"-y\",\n            (* also use a long option style (--yoohoo) *)\n            long=\"--yoohoo\"\n           );\n\n    (* A dummy option to pretty-print the usage *)\n    Option ((* description of the option *)\n            descr=\"\",\n            dummy=true\n           );\n    Option ((* description of the option *)\n            descr=\"[Required Options]\",\n            descrColor=System.ConsoleColor.DarkCyan,\n            dummy=true\n           );\n\n    (* The third option is a required option. In other words, option parsing\n       will raise an exception if this option is not given by a user. This\n       option takes in an additional integer argument, and set it to the global\n       variable z. *)\n    Option ((* description of the option *)\n            descr=\"required parameter \u003cSTRING\u003e with an integer option\",\n            (* callback to set the optZ value *)\n            callback=(fun opts arg -\u003e {opts with optZ=arg.[0]}),\n            (* specifying this is a required option *)\n            required=true,\n            (* one additional argument to specify an integer value *)\n            extra=1,\n            (* use only a long option style *)\n            long=\"--req\"\n           );\n  ]\n\n[\u003cEntryPoint\u003e]\nlet main (args:string[]) =\n  let prog = \"opttest.fsx\"\n  let args = System.Environment.GetCommandLineArgs ()\n  let usageGetter () = \"[Usage]\\n  %p %o\"\n  try\n    let left, opts = optParse spec usageGetter prog args defaultOpts\n    printfn \"Rest args: %A, x: %d, y: %b, z: %s\"\n      left opts.optX opts.optY opts.optZ\n    0\n  with\n    | SpecErr msg -\u003e\n        eprintfn \"Invalid spec: %s\" msg\n        exit 1\n    | RuntimeErr msg -\u003e\n        eprintfn \"Invalid args given by user: %s\" msg\n        usagePrint spec prog usageGetter (fun () -\u003e exit 1)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb2r2-org%2Ffsoptparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb2r2-org%2Ffsoptparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb2r2-org%2Ffsoptparse/lists"}