{"id":1433,"date":"2022-10-13T08:41:09","date_gmt":"2022-10-13T08:41:09","guid":{"rendered":"https:\/\/www.liutianfeng.com\/?p=1433"},"modified":"2022-10-13T08:42:56","modified_gmt":"2022-10-13T08:42:56","slug":"shell%e8%af%bb%e5%8f%96yaml%e6%96%87%e4%bb%b6-shyaml","status":"publish","type":"post","link":"https:\/\/www.liutianfeng.com\/?p=1433","title":{"rendered":"Shell\u8bfb\u53d6yaml\u6587\u4ef6 &#8211; shyaml"},"content":{"rendered":"<h4>\u5b89\u88c5<\/h4>\n<pre class=\"pure-highlightjs\"><code class=\"\"># pip3 install shyaml<\/code><\/pre>\n<h4>\u5e2e\u52a9<\/h4>\n<pre class=\"pure-highlightjs\"><code class=\"\"># shyaml --help\r\n\r\nParses and output chosen subpart or values from YAML input.\r\nIt reads YAML in stdin and will output on stdout it's return value.\r\n\r\nUsage:\r\n\r\n    shyaml {-h|--help}\r\n    shyaml {-V|--version}\r\n    shyaml [-y|--yaml] [-q|--quiet] ACTION KEY [DEFAULT]\r\n\r\n\r\nOptions:\r\n\r\n    -y, --yaml\r\n              Output only YAML safe value, more precisely, even\r\n              literal values will be YAML quoted. This behavior\r\n              is required if you want to output YAML subparts and\r\n              further process it. If you know you have are dealing\r\n              with safe literal value, then you don't need this.\r\n              (Default: no safe YAML output)\r\n\r\n    -q, --quiet\r\n              In case KEY value queried is an invalid path, quiet\r\n              mode will prevent the writing of an error message on\r\n              standard error.\r\n              (Default: no quiet mode)\r\n\r\n    -L, --line-buffer\r\n              Force parsing stdin line by line allowing to process\r\n              streamed YAML as it is fed instead of buffering\r\n              input and treating several YAML streamed document\r\n              at once. This is likely to have some small performance\r\n              hit if you have a huge stream of YAML document, but\r\n              then you probably don't really care about the\r\n              line-buffering.\r\n              (Default: no line buffering)\r\n\r\n    ACTION    Depending on the type of data you've targetted\r\n              thanks to the KEY, ACTION can be:\r\n\r\n              These ACTIONs applies to any YAML type:\r\n\r\n                get-type          ## returns a short string\r\n                get-value         ## returns YAML\r\n\r\n              These ACTIONs applies to 'sequence' and 'struct' YAML type:\r\n\r\n                get-values{,-0}   ## returns list of YAML\r\n                get-length        ## returns an integer\r\n\r\n              These ACTION applies to 'struct' YAML type:\r\n\r\n                keys{,-0}         ## returns list of YAML\r\n                values{,-0}       ## returns list of YAML\r\n                key-values,{,-0}  ## returns list of YAML\r\n\r\n              Note that any value returned is returned on stdout, and\r\n              when returning ``list of YAML``, it'll be separated by\r\n              a newline or ``NUL`` char depending of you've used the\r\n              ``-0`` suffixed ACTION.\r\n\r\n    KEY       Identifier to browse and target subvalues into YAML\r\n              structure. Use ``.`` to parse a subvalue. If you need\r\n              to use a literal ``.`` or ``\\``, use ``\\`` to quote it.\r\n\r\n              Use struct keyword to browse ``struct`` YAML data and use\r\n              integers to browse ``sequence`` YAML data.\r\n\r\n    DEFAULT   if not provided and given KEY do not match any value in\r\n              the provided YAML, then DEFAULT will be returned. If no\r\n              default is provided and the KEY do not match any value\r\n              in the provided YAML, shyaml will fail with an error\r\n              message.\r\n\r\nExamples:\r\n\r\n     ## get last grocery\r\n     cat recipe.yaml       | shyaml get-value groceries.-1\r\n\r\n     ## get all words of my french dictionary\r\n     cat dictionaries.yaml | shyaml keys-0 french.dictionary\r\n\r\n     ## get YAML config part of 'myhost'\r\n     cat hosts_config.yaml | shyaml get-value cfgs.myhost<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.liutianfeng.com\">liutianfeng.com<\/a> &raquo; <a href=\"https:\/\/www.liutianfeng.com\/?p=1433\">Shell\u8bfb\u53d6yaml\u6587\u4ef6 &#8211; shyaml<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5 # pip3 install shyaml \u5e2e\u52a9 # shyaml &#8211;help Parses and  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[],"_links":{"self":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/1433"}],"collection":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1433"}],"version-history":[{"count":1,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/1433\/revisions"}],"predecessor-version":[{"id":1434,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/1433\/revisions\/1434"}],"wp:attachment":[{"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liutianfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}