5.12.104 • Published 11 months ago

@patrtorg/quibusdam-minima v5.12.104

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@patrtorg/quibusdam-minima

Transpile curl commands into C, C#, ColdFusion, Clojure, Dart, Elixir, Go, HTTPie, Java, JavaScript, Julia, Kotlin, Lua, MATLAB, Objective-C, OCaml, Perl, PHP, PowerShell, Python, R, Ruby, Rust, Swift, Wget, Ansible, HAR, HTTP or JSON.

Try it on @patrtorg/quibusdam-minima.com or as a drop-in curl replacement:

$ @patrtorg/quibusdam-minima --data "hello=world" example.com
import requests

data = {
    'hello': 'world',
}

response = requests.post('http://example.com', data=data)

Features:

  • Implements a lot of curl's argument parsing logic
    • Knows about all 255 curl arguments but most are ignored
    • Supports shortening -O -v -X POST to -OvXPOST
    • --data @filename generates code that reads that file and @- reads stdin
  • Understands Bash syntax
    • ANSI-C quoted strings
    • stdin redirects and heredocs
    • Generated code reads environment variables and runs subcommands
    • Ignores comments
    • Reports syntax errors
  • Converts JSON data to native objects
  • Warns about issues with the conversion

Limitations:

  • Only HTTP is supported
  • Code generators for other languages are less thorough than the Python generator
  • curl doesn't follow redirects or decompress gzip-compressed responses by default, but the generated code will do whatever the default is for that runtime, to keep it shorter. For example Python's Requests library follows redirects by default, so unless you explicitly set the redirect policy with -L/--location/--no-location, the generated code will not handle redirects the same way as the curl command
  • Shell variables can arbitrarily change how the command would be parsed at runtime. The command curl $VAR can do anything, depending on what's in $VAR. @patrtorg/quibusdam-minima assumes that environment variables don't contain characters that would affect parsing
  • Only simple subcommands such as curl $(echo example.com) work, more complicated subcommands (such as nested commands or subcommands that redirect the output) won't generate valid code
  • The Bash parser doesn't support all Bash syntax
  • and much more

Install

Install the command line tool with

npm install --global @patrtorg/quibusdam-minima

Install the JavaScript library for use in your own projects with

npm install @patrtorg/quibusdam-minima

@patrtorg/quibusdam-minima requires Node 12+.

Usage

Usage from the command line

@patrtorg/quibusdam-minima acts as a drop-in replacement for curl. Take any curl command, change "curl" to "@patrtorg/quibusdam-minima" and it will print code instead of making the request

$ @patrtorg/quibusdam-minima example.com
import requests

response = requests.get('http://example.com')

To read the curl command from stdin, pass -

$ echo 'curl example.com' | @patrtorg/quibusdam-minima -
import requests

response = requests.get('http://example.com')

Choose the output language by passing --language <language>. The options are

  • ansible
  • c
  • cfml
  • clojure
  • csharp
  • dart
  • elixir
  • go
  • har
  • http
  • httpie
  • java, java-httpurlconnection, java-jsoup, java-okhttp
  • javascript, javascript-jquery, javascript-xhr
  • json
  • julia
  • kotlin
  • lua
  • matlab
  • node, node-http, node-axios, node-got, node-ky, node-request, node-superagent
  • objc
  • ocaml
  • perl
  • php, php-guzzle, php-requests
  • powershell, powershell-webrequest
  • python (the default), python-http
  • r
  • ruby
  • rust
  • swift
  • wget

--verbose enables printing of conversion warnings and error tracebacks.

Usage as a library

The JavaScript API is a bunch of functions that can take either a string of Bash code or an array of already-parsed arguments (like process.argv) and return a string with the resulting program:

import * as @patrtorg/quibusdam-minima from '@patrtorg/quibusdam-minima';

@patrtorg/quibusdam-minima.toPython('curl example.com');
@patrtorg/quibusdam-minima.toPython(['curl', 'example.com']);
// "import requests\n\nresponse = requests.get('http://example.com')\n"

Note: add "type": "module", to your package.json for the import statement above to work. @patrtorg/quibusdam-minima must be imported as an ES module with import this way and not with require() because it uses top-level await.

There's a corresponding set of functions that also return an array of warnings if there are any issues with the conversion:

@patrtorg/quibusdam-minima.toPythonWarn('curl ftp://example.com');
@patrtorg/quibusdam-minima.toPythonWarn(['curl', 'ftp://example.com']);
// [
//   "import requests\n\nresponse = requests.get('ftp://example.com')\n",
//   [ [ 'bad-scheme', 'Protocol "ftp" not supported' ] ]
// ]

If you want to host @patrtorg/quibusdam-minima yourself and use it in the browser, it needs two WASM files to work, tree-sitter.wasm and tree-sitter-bash.wasm, which it will request from the root directory of your web server. If you are hosting a static website and using Webpack, you need to copy these files from the node_modules/ directory to your server's root directory in order to serve them. You can look at the webpack.config.js for @patrtorg/quibusdam-minima.com to see how this is done. You will also need to set {module: {experiments: {topLevelAwait: true}}} in your webpack.config.js.

Usage in VS Code

There's a VS Code extension that adds a "Paste cURL as \<language>" option to the right-click menu: https://marketplace.visualstudio.com/items?itemName=@patrtorg/quibusdam-minima.@patrtorg/quibusdam-minima. It doesn't support the same languages, curl arguments or Bash syntax as the current version because it has to use an old version of @patrtorg/quibusdam-minima.

Contributing

See CONTRIBUTING.md

License

MIT © Nick Carneiro

slicevisualReactiveX256descriptionsyntaxerrorweb_.extendpreprocessorautoscalingiesharedarraybufferincludesECMAScript 2022HyBistringmetadatahigher-orderecmascriptdotenvRFC-6455east-asian-widthes6functionscloudtrailcall-bindzxkeyURLSearchParamsinputenumerableArray.prototype.containsastloggerdomkeysjestsuperstructnpmvestxhrintrinsicargsagentstringifierpropertiesenderimmutablesideidleflattenES5definecall-boundReactiveExtensionsatomamazonformattingdescriptorsspawnES3ArrayBuffershebangcommanderlockfilefullcallbindrssframerfixed-widthhardlinksutil.inspectterminalprotobufcss-in-jstapreversedpropertyArraycjkbannerserializearraybufferutilitycopyfull-widthpackageESpopmotionemitprefixes2015eslintpluginsortdebuggerObservableszodpostcsslook-uptypesloadbalancingRegExp.prototype.flagsfantasy-landtypeofBigUint64ArrayjsxdescriptornodegetoptECMAScript 2021route53escapegetOwnPropertyDescriptorhas-ownruntimetypedarraydeterministicargumentAsyncIteratorreduxreal-timeECMAScript 6typedarrayscloneRxJSlistenerstrimLeftforknumberweaksetmomentrdsstyleguideglobal this valuetypeerrorflagdateworkermovenameglobal objectparenttoReversedserializercloudformationjson-schema-validatoreventEmitter.envclass-validatorobjES2017elbnamesString.prototype.trimobjectECMAScript 3CSSStyleDeclarationwaittrimRightArray.prototype.findLastlookvarreact-hook-formvpctoolkit$.extendowndebugvalidvaluecryptos3equal0fsbrowsersliststoragegatewayexpressiongdprwritableexecfiletacitrfc4122io-tscodesreadablestreamform-validationvalidatorfpfinduptstoArray[[Prototype]]settingsrulesassigndataViewperformancebeanstalkuuidgroupBymulti-packagemruredux-toolkitArrayBuffer.prototype.slicerm -frpropprototypewhichkoreanfast-deep-cloneflatMapqueueMicrotaskartestreepackagesphoneunicodechromiumprotocontainssomepathECMAScript 2019forEachsyntaxjson-schema-validationexechtmlchaiCSSclassestrimStartES7JSONcurriedObject.keysStream3dsafeMapindicatorInt16Arrayshimreusepruneoffsetcolorstesterloadingroutereslint-pluginfetchcoverageajaxtranspilernativeReflect.getPrototypeOfemojistyle@@toStringTagfpshasOwnpackage.jsonregexshellserializationbddroutingjsdiffsortedmanipulationcallboundqueryawsschemewalkingacornpyyamlECMAScript 2015inferencepolyfilldeep-copyredactcalleveryES2022setPrototypeOfconsumeframeworkclientchromecloudsearchES2016Streamsregular-expressionFunction.prototype.nameInt8ArraybrowsertestWeakSetessymlinks6to5toSortedargvasciiArray.prototype.flatMaptestingSystem.globalbinarymatchesa11ysubprocessansifindLastIndexcomputed-typesparsechinesestructuredClonermdirbindi18nexpresspositivetextbufferjQueryuser-streamses2018Object.entriespicomatchhelpersconfigurablehttpcssaccessibilityfast-copychildWebSocketECMAScript 2018localdependency managerfigletwalkES2018assertsuninstallisvarsmoduleUint32Arrayremoveformpatchlastpluginreact posemakehashhelperidwgetschemaprocesspushsymbolsregular expressionpoint-freedeletetoStringTaggetPrototypeOftc39characterrgbassertUint16Arrayec2importexportECMAScript 2017asterisksspringfast-cloneTypeBoxhttpssameValueZeroArray.prototype.flattenextraarrayes-abstractlanguagecircularnpmignorewidthcoerciblelintspeccoregetterArray.prototype.findLastIndextimebundlingcheckUint8Arraymake dirmochamapreducearraysinstallerponyfillmergecolumnglobfindLastfilterjsimportmkdirtypescriptlogfnmatchdefinePropertyInt32ArraymatchshamPromisecode pointsflagsswfconstsettoolswafES2023jshintendpointcolumnsquotettyerrorPushreducerjsonschemabrowserlistqsassertionconcatMapjson-schemaimmeridentifierscacheES6Array.prototype.filterFloat64ArrayentriescensoreslintUint8ClampedArrayjsoneffect-tsenvironmentrmavadragredirectfullwidthObservabledynamodbinspectslotutilitiestypesafefastasyncwindowspeedappECMAScript 7es-shim APInodejsaccessor.gitignoretranspileweakmapfunction.lengthworkflowes8kinesistslibl10nreact-hooksfiledom-testing-librarybyteLengthglobalsemrESnextstablearktypeString.prototype.matchAllespreeshrinkwrapsharedzerodayjsmatchAllparserrequestanimationxtermbyteOffsetreact animationWebSocketsclassnamevalueswhatwgdroptakeECMAScript 5touchisConcatSpreadablegesturesObject.getPrototypeOfprettydeepECMAScript 2023ES8threehookstostringtagcloudwatchiteratorscheme-validationeslintconfigconfigrestinstallnegativeArray.prototype.includesECMAScript 2020waapioptimizerstylesquerystringreverseYAMLSymbol.toStringTagtypedcreateECMAScript 2016graphqlmobileebspromiseSetrangeerrortoobjectcallbackbufferschannelkarmautilstreamsextendfastcopyprotocol-buffersformatcollectionglaciergloballinkStyleSheetES2020ArrayBuffer#slicesetImmediatesnssymbolfast-deep-copydataviewtransportsuperagentwarningUnderscoreignorereactsimpledbtddinvariantcolourfind-upefficientmkdirsbytemkdirpreact-testing-libraryelasticacherapidvalidategetintrinsices2017source mapRxapibabelboundinternal slotsesbundlertapeES2021postcss-pluginairbnbconcatenvironmentsfastcloneeventDispatcherpinocompilerWeakMappnpm9functionaloutputsinatraURLglobalThisSymbolcloudfrontdeepcopyrestfuldirectoryoptimistyamlbusy
5.12.104

11 months ago

5.12.103

11 months ago

5.12.102

11 months ago

5.12.101

11 months ago

5.12.100

11 months ago

5.12.99

11 months ago

5.11.99

11 months ago

5.10.99

11 months ago

5.10.98

11 months ago

5.9.98

11 months ago

5.9.97

11 months ago

5.9.96

11 months ago

5.9.95

11 months ago

5.9.94

11 months ago

5.9.93

11 months ago

5.9.92

11 months ago

5.9.91

11 months ago

5.9.90

11 months ago

5.9.89

11 months ago

5.9.88

11 months ago

5.9.87

11 months ago

5.9.86

12 months ago

5.9.85

12 months ago

5.9.84

12 months ago

5.8.84

12 months ago

5.8.83

12 months ago

5.8.82

12 months ago

5.7.82

12 months ago

5.7.81

12 months ago

5.7.80

12 months ago

5.7.79

12 months ago

5.7.78

12 months ago

5.7.77

12 months ago

5.7.76

12 months ago

5.7.75

12 months ago

5.7.74

12 months ago

5.7.73

12 months ago

5.7.72

12 months ago

5.7.71

12 months ago

5.7.70

12 months ago

4.7.70

12 months ago

4.7.69

1 year ago

4.7.68

1 year ago

4.7.67

1 year ago

4.7.66

1 year ago

4.7.65

1 year ago

3.7.65

1 year ago

3.7.64

1 year ago

3.7.63

1 year ago

3.7.62

1 year ago

3.7.61

1 year ago

3.7.60

1 year ago

3.7.59

1 year ago

3.7.58

1 year ago

3.7.57

1 year ago

3.7.56

1 year ago

3.7.55

1 year ago

3.7.54

1 year ago

3.7.53

1 year ago

2.7.53

1 year ago

2.7.52

1 year ago

2.7.51

1 year ago

1.7.51

1 year ago

1.7.50

1 year ago

1.7.49

1 year ago

1.7.48

1 year ago

1.7.47

1 year ago

1.6.47

1 year ago

1.6.46

1 year ago

1.6.45

1 year ago

1.5.45

1 year ago

1.5.44

1 year ago

1.5.43

1 year ago

1.5.42

1 year ago

1.5.41

1 year ago

1.5.40

1 year ago

1.5.39

1 year ago

1.5.38

1 year ago

1.5.37

1 year ago

1.5.36

1 year ago

1.4.36

1 year ago

1.4.35

1 year ago

1.4.34

1 year ago

1.4.33

1 year ago

1.4.32

1 year ago

1.3.32

1 year ago

1.3.31

1 year ago

1.3.30

1 year ago

1.3.29

1 year ago

1.3.28

1 year ago

1.3.27

1 year ago

1.3.26

1 year ago

1.2.26

1 year ago

1.2.25

1 year ago

1.2.24

1 year ago

1.2.23

1 year ago

1.2.22

1 year ago

1.2.21

1 year ago

1.2.20

1 year ago

1.2.19

1 year ago

1.2.18

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago