From 2063b6a0685d90507cb12260b822bec65d69559f Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 3 May 2024 13:13:42 +0200 Subject: [PATCH] Remove `yaml` output format from `--format` flag. / Deprecate `--format json` in favor of `--json` (#2587) * Removed 'yaml' output from '--format' flag * Deprecated '--format json' in favor of '--json' * Updated all --format json references to use --json --- .licenses/go/sigs.k8s.io/yaml.dep.yml | 317 ---------- .../go/sigs.k8s.io/yaml/goyaml.v2.dep.yml | 571 ------------------ docs/UPGRADING.md | 4 + docs/getting-started.md | 37 +- docs/versioning.md | 4 +- go.mod | 1 - go.sum | 3 - internal/cli/cli.go | 11 +- internal/cli/core/upgrade.go | 2 +- internal/cli/feedback/feedback.go | 12 - internal/integrationtest/arduino-cli.go | 2 +- internal/integrationtest/board/board_test.go | 40 +- .../board/hardware_loading_test.go | 16 +- .../integrationtest/compile_1/compile_test.go | 8 +- .../compile_3/compile_commands_test.go | 2 +- .../compile_3/compile_show_properties_test.go | 14 +- .../integrationtest/compile_3/compile_test.go | 8 +- .../compile_3/lib_selection_test.go | 4 +- .../integrationtest/compile_4/compile_test.go | 2 +- .../integrationtest/config/config_test.go | 85 ++- internal/integrationtest/core/core_test.go | 106 ++-- internal/integrationtest/debug/debug_test.go | 28 +- internal/integrationtest/lib/lib_test.go | 100 +-- internal/integrationtest/main/main_test.go | 4 +- .../integrationtest/profiles/profiles_test.go | 16 +- .../integrationtest/upload/upload_test.go | 10 +- 26 files changed, 257 insertions(+), 1150 deletions(-) delete mode 100644 .licenses/go/sigs.k8s.io/yaml.dep.yml delete mode 100644 .licenses/go/sigs.k8s.io/yaml/goyaml.v2.dep.yml diff --git a/.licenses/go/sigs.k8s.io/yaml.dep.yml b/.licenses/go/sigs.k8s.io/yaml.dep.yml deleted file mode 100644 index 75c8789ff5d..00000000000 --- a/.licenses/go/sigs.k8s.io/yaml.dep.yml +++ /dev/null @@ -1,317 +0,0 @@ ---- -name: sigs.k8s.io/yaml -version: v1.4.0 -type: go -summary: -homepage: https://pkg.go.dev/sigs.k8s.io/yaml -license: other -licenses: -- sources: LICENSE - text: | - The MIT License (MIT) - - Copyright (c) 2014 Sam Ghods - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - - - Copyright (c) 2012 The Go Authors. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - # The forked go-yaml.v3 library under this project is covered by two - different licenses (MIT and Apache): - - #### MIT License #### - - The following files were ported to Go from C files of libyaml, and thus - are still covered by their original MIT license, with the additional - copyright staring in 2011 when the project was ported over: - - apic.go emitterc.go parserc.go readerc.go scannerc.go - writerc.go yamlh.go yamlprivateh.go - - Copyright (c) 2006-2010 Kirill Simonov - Copyright (c) 2006-2011 Kirill Simonov - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - - ### Apache License ### - - All the remaining project files are covered by the Apache license: - - Copyright (c) 2011-2019 Canonical Ltd - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - # The forked go-yaml.v2 library under the project is covered by an - Apache license: - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -notices: [] diff --git a/.licenses/go/sigs.k8s.io/yaml/goyaml.v2.dep.yml b/.licenses/go/sigs.k8s.io/yaml/goyaml.v2.dep.yml deleted file mode 100644 index 685cc250260..00000000000 --- a/.licenses/go/sigs.k8s.io/yaml/goyaml.v2.dep.yml +++ /dev/null @@ -1,571 +0,0 @@ ---- -name: sigs.k8s.io/yaml/goyaml.v2 -version: v1.4.0 -type: go -summary: Package yaml implements YAML support for the Go language. -homepage: https://pkg.go.dev/sigs.k8s.io/yaml/goyaml.v2 -license: other -licenses: -- sources: LICENSE - text: |2 - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -- sources: yaml@v1.4.0/LICENSE - text: | - The MIT License (MIT) - - Copyright (c) 2014 Sam Ghods - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - - - Copyright (c) 2012 The Go Authors. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - # The forked go-yaml.v3 library under this project is covered by two - different licenses (MIT and Apache): - - #### MIT License #### - - The following files were ported to Go from C files of libyaml, and thus - are still covered by their original MIT license, with the additional - copyright staring in 2011 when the project was ported over: - - apic.go emitterc.go parserc.go readerc.go scannerc.go - writerc.go yamlh.go yamlprivateh.go - - Copyright (c) 2006-2010 Kirill Simonov - Copyright (c) 2006-2011 Kirill Simonov - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - - ### Apache License ### - - All the remaining project files are covered by the Apache license: - - Copyright (c) 2011-2019 Canonical Ltd - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - # The forked go-yaml.v2 library under the project is covered by an - Apache license: - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -- sources: LICENSE.libyaml - text: | - The following files were ported to Go from C files of libyaml, and thus - are still covered by their original copyright and license: - - apic.go - emitterc.go - parserc.go - readerc.go - scannerc.go - writerc.go - yamlh.go - yamlprivateh.go - - Copyright (c) 2006 Kirill Simonov - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -- sources: README.md - text: The yaml package is licensed under the Apache License 2.0. Please see the - LICENSE file for details. -notices: -- sources: NOTICE - text: |- - Copyright 2011-2016 Canonical Ltd. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 009bf4daa38..ef245d67a75 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -4,6 +4,10 @@ Here you can find a list of migration guides to handle breaking changes between ## 0.36.0 +### YAML output format is no more supported + +The `yaml` option of the `--format` flag is no more supported. Use `--format json` if machine parsable output is needed. + ### The gRPC `cc.arduino.cli.commands.v1.CompileRequest.export_binaries` changed type. Previously the field `export_binaries` was a `google.protobuf.BoolValue`. We used this type because it expresses this diff --git a/docs/getting-started.md b/docs/getting-started.md index ad4de630496..ce3d804d6cd 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -8,34 +8,35 @@ IDE. Let's see some examples. ```console $ arduino-cli help core -Arduino Core operations. +Arduino core operations. Usage: - arduino-cli core [command] + arduino-cli core [command] Examples: - ./arduino-cli core update-index + arduino-cli core update-index Available Commands: - download Downloads one or more cores and corresponding tool dependencies. - install Installs one or more cores and corresponding tool dependencies. - list Shows the list of installed platforms. - search Search for a core in Boards Manager. - uninstall Uninstalls one or more cores and corresponding tool dependencies if no more used. - update-index Updates the index of cores. - upgrade Upgrades one or all installed platforms to the latest version. + download Downloads one or more cores and corresponding tool dependencies. + install Installs one or more cores and corresponding tool dependencies. + list Shows the list of installed platforms. + search Search for a core in Boards Manager. + uninstall Uninstalls one or more cores and corresponding tool dependencies if no longer used. + update-index Updates the index of cores. + upgrade Upgrades one or all installed platforms to the latest version. Flags: - -h, --help help for core + -h, --help help for core Global Flags: - --additional-urls strings Additional URLs for Boards Manager. - --config-file string The custom config file (if not specified the default will be used). - --format string The output format, can be [text|json]. (default "text") - --log-file string Path to the file where logs will be written. - --log-format string The output format for the logs, can be [text|json]. - --log-level string Messages with this level and above will be logged. - -v, --verbose Print the logs on the standard output. + --additional-urls strings Comma-separated list of additional URLs for the Boards Manager. + --config-file string The custom config file (if not specified the default will be used). + --json Print the output in JSON format. + --log Print the logs on the standard output. + --log-file string Path to the file where logs will be written. + --log-format string The output format for the logs, can be: text, json + --log-level string Messages with this level and above will be logged. Valid levels are: trace, debug, info, warn, error, fatal, panic + --no-color Disable colored output. Use "arduino-cli core [command] --help" for more information about a command. ``` diff --git a/docs/versioning.md b/docs/versioning.md index ef8977300ba..02cccd398d0 100644 --- a/docs/versioning.md +++ b/docs/versioning.md @@ -45,8 +45,8 @@ The following changes to the command-line syntax are NOT considered breaking: Any change in the **human-readable** text output is **NOT** considered a breaking change. In general, the human-readable text is subject to translation and small adjustments in natural language syntax and presentation. -We will consider breaking changes only in the **machine-readable** output of the commands using the `--format json` -flag. In particular, we have a breaking change in the JSON command output if: +We will consider breaking changes only in the **machine-readable** output of the commands using the `--json` flag. In +particular, we have a breaking change in the JSON command output if: - a key in a JSON object is renamed or removed. - a value in a JSON object or array changes meaning or changes format. diff --git a/go.mod b/go.mod index 13185198605..456892b5006 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,6 @@ require ( google.golang.org/grpc v1.62.1 google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v3 v3.0.1 - sigs.k8s.io/yaml v1.4.0 ) require ( diff --git a/go.sum b/go.sum index 09d06141c32..22de80e17f5 100644 --- a/go.sum +++ b/go.sum @@ -82,7 +82,6 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg= @@ -300,5 +299,3 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= -sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/internal/cli/cli.go b/internal/cli/cli.go index ba6214967cc..da265d46f59 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -58,6 +58,7 @@ import ( var ( verbose bool + jsonOutput bool outputFormat string configFile string ) @@ -75,6 +76,10 @@ func NewCommand() *cobra.Command { Long: tr("Arduino Command Line Interface (arduino-cli)."), Example: fmt.Sprintf(" %s <%s> [%s...]", os.Args[0], tr("command"), tr("flags")), PersistentPreRun: func(cmd *cobra.Command, args []string) { + if jsonOutput { + outputFormat = "json" + } + preRun(cmd, args) if cmd.Name() != "version" { @@ -150,11 +155,13 @@ func createCliCommandTree(cmd *cobra.Command) { cmd.RegisterFlagCompletionFunc("log-format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return validLogFormats, cobra.ShellCompDirectiveDefault }) - validOutputFormats := []string{"text", "json", "jsonmini", "yaml"} - cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", tr("The output format for the logs, can be: %s", strings.Join(validOutputFormats, ", "))) + validOutputFormats := []string{"text", "json", "jsonmini"} + cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", tr("The command output format, can be: %s", strings.Join(validOutputFormats, ", "))) cmd.RegisterFlagCompletionFunc("format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return validOutputFormats, cobra.ShellCompDirectiveDefault }) + cmd.Flag("format").Hidden = true + cmd.PersistentFlags().BoolVar(&jsonOutput, "json", false, tr("Print the output in JSON format.")) cmd.PersistentFlags().StringVar(&configFile, "config-file", "", tr("The custom config file (if not specified the default will be used).")) cmd.PersistentFlags().StringSlice("additional-urls", []string{}, tr("Comma-separated list of additional URLs for the Boards Manager.")) cmd.PersistentFlags().Bool("no-color", false, "Disable colored output.") diff --git a/internal/cli/core/upgrade.go b/internal/cli/core/upgrade.go index 638246dc4f1..e98dd72b244 100644 --- a/internal/cli/core/upgrade.go +++ b/internal/cli/core/upgrade.go @@ -142,7 +142,7 @@ func Upgrade(inst *rpc.Instance, args []string, skipPostInstall bool, skipPreUni feedback.PrintResult(&platformUpgradeResult{}) } -// This is needed so we can print warning messages in case users use --format json +// This is needed so we can print warning messages in case users use --json type platformUpgradeResult struct{} // Data implements feedback.Result. diff --git a/internal/cli/feedback/feedback.go b/internal/cli/feedback/feedback.go index 04b5ba336c1..db98749bd41 100644 --- a/internal/cli/feedback/feedback.go +++ b/internal/cli/feedback/feedback.go @@ -26,7 +26,6 @@ import ( "github.com/arduino/arduino-cli/internal/i18n" "github.com/sirupsen/logrus" - "sigs.k8s.io/yaml" ) // OutputFormat is an output format @@ -39,14 +38,11 @@ const ( JSON // MinifiedJSON format MinifiedJSON - // YAML format - YAML ) var formats = map[string]OutputFormat{ "json": JSON, "jsonmini": MinifiedJSON, - "yaml": YAML, "text": Text, } @@ -204,8 +200,6 @@ func Fatal(errorMsg string, exitCode ExitCode) { d, _ = json.MarshalIndent(augment(res), "", " ") case MinifiedJSON: d, _ = json.Marshal(augment(res)) - case YAML: - d, _ = yaml.Marshal(augment(res)) default: panic("unknown output format") } @@ -250,12 +244,6 @@ func PrintResult(res Result) { Fatal(tr("Error during JSON encoding of the output: %v", err), ErrGeneric) } data = string(d) - case YAML: - d, err := yaml.Marshal(augment(res.Data())) - if err != nil { - Fatal(tr("Error during YAML encoding of the output: %v", err), ErrGeneric) - } - data = string(d) case Text: data = res.String() if resErr, ok := res.(ErrorResult); ok { diff --git a/internal/integrationtest/arduino-cli.go b/internal/integrationtest/arduino-cli.go index f3266a7e153..3ec6f44f1ea 100644 --- a/internal/integrationtest/arduino-cli.go +++ b/internal/integrationtest/arduino-cli.go @@ -375,7 +375,7 @@ func (cli *ArduinoCLI) run(stdoutBuff, stderrBuff io.Writer, stdinBuff io.Reader // StartDaemon starts the Arduino CLI daemon. It returns the address of the daemon. func (cli *ArduinoCLI) StartDaemon(verbose bool) string { - args := []string{"daemon", "--format", "json"} + args := []string{"daemon", "--json"} if cli.cliConfigPath != nil { args = append([]string{"--config-file", cli.cliConfigPath.String()}, args...) } diff --git a/internal/integrationtest/board/board_test.go b/internal/integrationtest/board/board_test.go index 977de95a989..639a27d3a7b 100644 --- a/internal/integrationtest/board/board_test.go +++ b/internal/integrationtest/board/board_test.go @@ -36,7 +36,7 @@ func TestCorrectBoardListOrdering(t *testing.T) { require.NoError(t, err) _, _, err = cli.Run("core", "install", "arduino:avr") require.NoError(t, err) - jsonOut, _, err := cli.Run("board", "listall", "--format", "json") + jsonOut, _, err := cli.Run("board", "listall", "--json") require.NoError(t, err) requirejson.Query(t, jsonOut, "[.boards[] | .fqbn]", `[ "arduino:avr:yun", @@ -80,7 +80,7 @@ func TestBoardList(t *testing.T) { cli.InstallMockedSerialDiscovery(t) - stdout, _, err := cli.Run("board", "list", "--format", "json") + stdout, _, err := cli.Run("board", "list", "--json") require.NoError(t, err) // check is a valid json and contains a list of ports requirejson.Parse(t, stdout). @@ -97,7 +97,7 @@ func TestBoardListMock(t *testing.T) { cli.InstallMockedSerialDiscovery(t) - stdout, _, err := cli.Run("board", "list", "--format", "json") + stdout, _, err := cli.Run("board", "list", "--json") require.NoError(t, err) // check is a valid json and contains a list of ports @@ -136,7 +136,7 @@ func TestBoardListWithFqbnFilter(t *testing.T) { cli.InstallMockedSerialDiscovery(t) - stdout, _, err := cli.Run("board", "list", "-b", "foo:bar:baz", "--format", "json") + stdout, _, err := cli.Run("board", "list", "-b", "foo:bar:baz", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.detected_ports | length`, `0`) } @@ -150,7 +150,7 @@ func TestBoardListWithFqbnFilterInvalid(t *testing.T) { cli.InstallMockedSerialDiscovery(t) - _, stderr, err := cli.Run("board", "list", "-b", "yadayada", "--format", "json") + _, stderr, err := cli.Run("board", "list", "-b", "yadayada", "--json") require.Error(t, err) requirejson.Query(t, stderr, ".error", `"Invalid FQBN: not an FQBN: yadayada"`) } @@ -164,7 +164,7 @@ func TestBoardListall(t *testing.T) { _, _, err = cli.Run("core", "install", "arduino:avr@1.8.3") require.NoError(t, err) - stdout, _, err := cli.Run("board", "listall", "--format", "json") + stdout, _, err := cli.Run("board", "listall", "--json") require.NoError(t, err) requirejson.Query(t, stdout, ".boards | length", "26") @@ -224,7 +224,7 @@ func TestBoardListallWithManuallyInstalledPlatform(t *testing.T) { }) require.NoError(t, err) - stdout, _, err := cli.Run("board", "listall", "--format", "json") + stdout, _, err := cli.Run("board", "listall", "--json") require.NoError(t, err) requirejson.Query(t, stdout, ".boards | length", "17") @@ -274,11 +274,11 @@ func TestBoardDetails(t *testing.T) { require.NoError(t, err) // Test board listall with and without showing hidden elements - stdout, _, err := cli.Run("board", "listall", "MIPS", "--format", "json") + stdout, _, err := cli.Run("board", "listall", "MIPS", "--json") require.NoError(t, err) require.Equal(t, string(stdout), "{}\n") - stdout, _, err = cli.Run("board", "listall", "MIPS", "-a", "--format", "json") + stdout, _, err = cli.Run("board", "listall", "MIPS", "-a", "--json") require.NoError(t, err) requirejson.Contains(t, stdout, `{ "boards": [ @@ -288,7 +288,7 @@ func TestBoardDetails(t *testing.T) { ] }`) - stdout, _, err = cli.Run("board", "details", "-b", "arduino:samd:nano_33_iot", "--format", "json") + stdout, _, err = cli.Run("board", "details", "-b", "arduino:samd:nano_33_iot", "--json") require.NoError(t, err) requirejson.Contains(t, stdout, `{ @@ -425,7 +425,7 @@ func TestBoardSearch(t *testing.T) { _, _, err := cli.Run("update") require.NoError(t, err) - stdout, _, err := cli.Run("board", "search", "--format", "json") + stdout, _, err := cli.Run("board", "search", "--json") require.NoError(t, err) // Verifies boards are returned requirejson.NotEmpty(t, stdout) @@ -441,7 +441,7 @@ func TestBoardSearch(t *testing.T) { ]}`) // Search in non installed boards - stdout, _, err = cli.Run("board", "search", "--format", "json", "nano", "33") + stdout, _, err = cli.Run("board", "search", "--json", "nano", "33") require.NoError(t, err) // Verifies boards are returned requirejson.NotEmpty(t, stdout) @@ -457,7 +457,7 @@ func TestBoardSearch(t *testing.T) { _, _, err = cli.Run("core", "install", "arduino:avr@1.8.3") require.NoError(t, err) - stdout, _, err = cli.Run("board", "search", "--format", "json") + stdout, _, err = cli.Run("board", "search", "--json") require.NoError(t, err) requirejson.NotEmpty(t, stdout) // Verifies some FQBNs are now returned after installing a platform @@ -474,7 +474,7 @@ func TestBoardSearch(t *testing.T) { } ]}`) - stdout, _, err = cli.Run("board", "search", "--format", "json", "arduino", "yun") + stdout, _, err = cli.Run("board", "search", "--json", "arduino", "yun") require.NoError(t, err) requirejson.NotEmpty(t, stdout) requirejson.Contains(t, stdout, `{ @@ -494,7 +494,7 @@ func TestBoardSearch(t *testing.T) { }) require.NoError(t, err) - stdout, _, err = cli.Run("board", "search", "--format", "json") + stdout, _, err = cli.Run("board", "search", "--json") require.NoError(t, err) requirejson.NotEmpty(t, stdout) // Verifies some FQBNs are now returned after installing a platform @@ -531,7 +531,7 @@ func TestBoardSearch(t *testing.T) { } ]}`) - stdout, _, err = cli.Run("board", "search", "--format", "json", "mkr1000") + stdout, _, err = cli.Run("board", "search", "--json", "mkr1000") require.NoError(t, err) requirejson.NotEmpty(t, stdout) // Verifies some FQBNs are now returned after installing a platform @@ -557,7 +557,7 @@ func TestBoardAttach(t *testing.T) { require.NoError(t, err) { - stdout, _, err := cli.Run("board", "attach", "-b", "arduino:avr:uno", sketchPath.String(), "--format", "json") + stdout, _, err := cli.Run("board", "attach", "-b", "arduino:avr:uno", sketchPath.String(), "--json") require.NoError(t, err) requirejson.Query(t, stdout, ".fqbn", `"arduino:avr:uno"`) @@ -568,7 +568,7 @@ func TestBoardAttach(t *testing.T) { require.NotContains(t, string(yamlData), "default_protocol:") } { - stdout, _, err := cli.Run("board", "attach", "-p", "/dev/ttyACM0", "-l", "serial", sketchPath.String(), "--format", "json") + stdout, _, err := cli.Run("board", "attach", "-p", "/dev/ttyACM0", "-l", "serial", sketchPath.String(), "--json") require.NoError(t, err) requirejson.Query(t, stdout, ".fqbn", `"arduino:avr:uno"`) requirejson.Query(t, stdout, ".port.address", `"/dev/ttyACM0"`) @@ -581,7 +581,7 @@ func TestBoardAttach(t *testing.T) { require.Contains(t, string(yamlData), "default_protocol: serial") } { - stdout, _, err := cli.Run("board", "attach", "-p", "/dev/ttyACM0", sketchPath.String(), "--format", "json") + stdout, _, err := cli.Run("board", "attach", "-p", "/dev/ttyACM0", sketchPath.String(), "--json") require.NoError(t, err) requirejson.Query(t, stdout, ".fqbn", `"arduino:avr:uno"`) requirejson.Query(t, stdout, ".port.address", `"/dev/ttyACM0"`) @@ -594,7 +594,7 @@ func TestBoardAttach(t *testing.T) { require.NotContains(t, string(yamlData), "default_protocol:") } { - stdout, _, err := cli.Run("board", "attach", "-b", "arduino:samd:mkr1000", "-P", "atmel_ice", sketchPath.String(), "--format", "json") + stdout, _, err := cli.Run("board", "attach", "-b", "arduino:samd:mkr1000", "-P", "atmel_ice", sketchPath.String(), "--json") require.NoError(t, err) requirejson.Query(t, stdout, ".fqbn", `"arduino:samd:mkr1000"`) requirejson.Query(t, stdout, ".programmer", `"atmel_ice"`) diff --git a/internal/integrationtest/board/hardware_loading_test.go b/internal/integrationtest/board/hardware_loading_test.go index a5daacdd71c..758ce6a40d2 100644 --- a/internal/integrationtest/board/hardware_loading_test.go +++ b/internal/integrationtest/board/hardware_loading_test.go @@ -43,7 +43,7 @@ func TestHardwareLoading(t *testing.T) { t.Run("Simple", func(t *testing.T) { { - out, _, err := cli.Run("core", "list", "--format", "json") + out, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, out) jsonOut.LengthMustEqualTo(1) @@ -73,7 +73,7 @@ func TestHardwareLoading(t *testing.T) { { // Also test local platform.txt properties override - out, _, err := cli.Run("board", "details", "-b", "arduino:avr:uno", "--format", "json") + out, _, err := cli.Run("board", "details", "-b", "arduino:avr:uno", "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, out) jsonOut.MustContain(`{ @@ -100,7 +100,7 @@ func TestHardwareLoading(t *testing.T) { } { - out, _, err := cli.Run("board", "details", "-b", "arduino:avr:yun", "--format", "json") + out, _, err := cli.Run("board", "details", "-b", "arduino:avr:yun", "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, out) jsonOut.MustContain(`{ @@ -115,7 +115,7 @@ func TestHardwareLoading(t *testing.T) { { // Check un-expansion of board_properties - out, _, err := cli.Run("board", "details", "-b", "arduino:avr:robotMotor", "--show-properties=unexpanded", "--format", "json") + out, _, err := cli.Run("board", "details", "-b", "arduino:avr:robotMotor", "--show-properties=unexpanded", "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, out) jsonOut.MustContain(`{ @@ -131,7 +131,7 @@ func TestHardwareLoading(t *testing.T) { { // Also test local boards.txt properties override - out, _, err := cli.Run("board", "details", "-b", "arduino:avr:diecimila", "--show-properties=unexpanded", "--format", "json") + out, _, err := cli.Run("board", "details", "-b", "arduino:avr:diecimila", "--show-properties=unexpanded", "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, out) jsonOut.MustContain(`{ @@ -152,7 +152,7 @@ func TestHardwareLoading(t *testing.T) { require.NoError(t, customHwDir.CopyDirTo(cli.SketchbookDir().Join("hardware"))) { - out, _, err := cli.Run("core", "list", "--format", "json") + out, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, out) jsonOut.Query(`.platforms | length`).LengthMustEqualTo(3) @@ -217,7 +217,7 @@ func TestHardwareLoading(t *testing.T) { { // Also test local platform.txt properties override - out, _, err := cli.Run("board", "details", "-b", "arduino:avr:uno", "--format", "json") + out, _, err := cli.Run("board", "details", "-b", "arduino:avr:uno", "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, out) jsonOut.MustContain(`{ @@ -244,7 +244,7 @@ func TestHardwareLoading(t *testing.T) { } { - out, _, err := cli.Run("board", "details", "-b", "arduino:avr:yun", "--show-properties=unexpanded", "--format", "json") + out, _, err := cli.Run("board", "details", "-b", "arduino:avr:yun", "--show-properties=unexpanded", "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, out) jsonOut.MustContain(`{ diff --git a/internal/integrationtest/compile_1/compile_test.go b/internal/integrationtest/compile_1/compile_test.go index 554c7c9d365..6d6dd605602 100644 --- a/internal/integrationtest/compile_1/compile_test.go +++ b/internal/integrationtest/compile_1/compile_test.go @@ -164,7 +164,7 @@ func compileWithSimpleSketchCustomEnv(t *testing.T, env *integrationtest.Environ require.NoError(t, err) // Build sketch for arduino:avr:uno with json output - stdout, _, err = cli.RunWithCustomEnv(customEnv, "compile", "-b", fqbn, sketchPath.String(), "--format", "json") + stdout, _, err = cli.RunWithCustomEnv(customEnv, "compile", "-b", fqbn, sketchPath.String(), "--json") require.NoError(t, err) // check is a valid json and contains requested data var compileOutput map[string]interface{} @@ -516,7 +516,7 @@ func compileWithExportBinariesConfig(t *testing.T, env *integrationtest.Environm defer cli.WorkingDir().Join("arduino-cli.yaml").Remove() // Test if arduino-cli config file written in the previous run has the `always_export_binaries` flag set. - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Contains(t, stdout, ` { @@ -845,7 +845,7 @@ func TestCompileWithArchivesAndLongPaths(t *testing.T) { _, _, err = cli.Run("lib", "install", "ArduinoIoTCloud", "--config-file", "arduino-cli.yaml") require.NoError(t, err) - stdout, _, err := cli.Run("lib", "examples", "ArduinoIoTCloud", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("lib", "examples", "ArduinoIoTCloud", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) libOutput := strings.Trim(requirejson.Parse(t, stdout).Query(`.examples.[0].library.install_dir`).String(), `"`) sketchPath := paths.New(libOutput) @@ -1189,7 +1189,7 @@ void loop() { ` expected = strings.ReplaceAll(expected, "%SKETCH_PATH%", cpp.QuoteString(sketchPath.Join("SketchSimple.ino").String())) - jsonOut, _, err := cli.Run("compile", "-b", fqbn, "--preprocess", sketchPath.String(), "--format", "json") + jsonOut, _, err := cli.Run("compile", "-b", fqbn, "--preprocess", sketchPath.String(), "--json") require.NoError(t, err) var ex struct { CompilerOut string `json:"compiler_out"` diff --git a/internal/integrationtest/compile_3/compile_commands_test.go b/internal/integrationtest/compile_3/compile_commands_test.go index a680a76ec83..1abdfc9a056 100644 --- a/internal/integrationtest/compile_3/compile_commands_test.go +++ b/internal/integrationtest/compile_3/compile_commands_test.go @@ -36,7 +36,7 @@ func TestCompileCommandsJSONGeneration(t *testing.T) { require.NoError(t, err) // Create a test sketch - out, _, err := cli.Run("sketch", "new", "Test", "--format", "json") + out, _, err := cli.Run("sketch", "new", "Test", "--json") require.NoError(t, err) var s struct { Path string `json:"sketch_path"` diff --git a/internal/integrationtest/compile_3/compile_show_properties_test.go b/internal/integrationtest/compile_3/compile_show_properties_test.go index 01ebc382d9a..c7b400167fc 100644 --- a/internal/integrationtest/compile_3/compile_show_properties_test.go +++ b/internal/integrationtest/compile_3/compile_show_properties_test.go @@ -51,9 +51,9 @@ func TestCompileShowProperties(t *testing.T) { require.True(t, props.ContainsKey("sketch_path")) require.NotContains(t, props.Get("archive_file_path"), "{build.path}") - // Test --show-properties --format JSON output is clean + // Test --show-properties --json JSON output is clean // properties are expanded - stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:uno", "-v", "--show-properties", "--format", "json", bareMinimum.String()) + stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:uno", "-v", "--show-properties", "--json", bareMinimum.String()) require.NoError(t, err) require.Empty(t, stderr) props, err = properties.LoadFromSlice( @@ -69,8 +69,8 @@ func TestCompileShowProperties(t *testing.T) { require.NoError(t, err, "Output must be a clean property list") require.NotEmpty(t, stderr) - // Test --show-properties --format JSON output is clean, with a wrong FQBN - stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:unoa", "-v", "--show-properties", "--format", "json", bareMinimum.String()) + // Test --show-properties --json JSON output is clean, with a wrong FQBN + stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:unoa", "-v", "--show-properties", "--json", bareMinimum.String()) require.Error(t, err) require.Empty(t, stderr) requireCompileResponseJson(t, stdout) @@ -87,7 +87,7 @@ func TestCompileShowProperties(t *testing.T) { // Test --show-properties=unexpanded output is clean // properties are not expanded - stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:uno", "-v", "--show-properties=unexpanded", "--format", "json", bareMinimum.String()) + stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:uno", "-v", "--show-properties=unexpanded", "--json", bareMinimum.String()) require.NoError(t, err) require.Empty(t, stderr) props, err = properties.LoadFromSlice( @@ -106,9 +106,9 @@ func TestCompileShowProperties(t *testing.T) { require.True(t, props.ContainsKey("archive_file_path")) require.NotContains(t, props.Get("archive_file_path"), "{build.path}") - // Test --show-properties=expanded --format JSON output is clean + // Test --show-properties=expanded --json JSON output is clean // properties are expanded - stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:uno", "-v", "--show-properties=expanded", "--format", "json", bareMinimum.String()) + stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:uno", "-v", "--show-properties=expanded", "--json", bareMinimum.String()) require.NoError(t, err) require.Empty(t, stderr) props, err = properties.LoadFromSlice( diff --git a/internal/integrationtest/compile_3/compile_test.go b/internal/integrationtest/compile_3/compile_test.go index 076e55b4597..aabd30445d0 100644 --- a/internal/integrationtest/compile_3/compile_test.go +++ b/internal/integrationtest/compile_3/compile_test.go @@ -113,7 +113,7 @@ func TestCompilerErrOutput(t *testing.T) { require.NoError(t, err) // Run compile and catch err stream - out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String()) + out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--json", sketch.String()) require.Error(t, err) outJson := requirejson.Parse(t, out) outJson.Query(`.compiler_err`).MustContain(`"error"`) @@ -135,7 +135,7 @@ func TestCompilerErrOutput(t *testing.T) { require.NoError(t, err) // Run compile and catch err stream - out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String()) + out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--json", sketch.String()) require.Error(t, err) outJson := requirejson.Parse(t, out) outJson.Query(`.success`).MustContain(`false`) @@ -161,7 +161,7 @@ func TestCompilerErrOutput(t *testing.T) { require.NoError(t, err) // Run compile and catch err stream - out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String()) + out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--json", sketch.String()) require.Error(t, err) outJson := requirejson.Parse(t, out) outJson.Query(`.success`).MustContain(`false`) @@ -185,7 +185,7 @@ func TestCompilerErrOutput(t *testing.T) { require.NoError(t, err) // Run compile and catch err stream - out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String()) + out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--json", sketch.String()) require.NoError(t, err) jsonOut := requirejson.Parse(t, out) jsonOut.Query(".compiler_out").MustNotContain(`"fatal error"`) diff --git a/internal/integrationtest/compile_3/lib_selection_test.go b/internal/integrationtest/compile_3/lib_selection_test.go index a999384d583..93c58acd529 100644 --- a/internal/integrationtest/compile_3/lib_selection_test.go +++ b/internal/integrationtest/compile_3/lib_selection_test.go @@ -45,7 +45,7 @@ func TestCompileLibrarySelection(t *testing.T) { // Perform two compile: // - the first should use LibraryA - stdout, _, err := cli.RunWithCustomEnv(vars, "compile", "-b", "arduino:avr:mega", "--format", "json", sketch.String()) + stdout, _, err := cli.RunWithCustomEnv(vars, "compile", "-b", "arduino:avr:mega", "--json", sketch.String()) require.NoError(t, err) requirejson.Contains(t, stdout, `{ "builder_result" : { @@ -56,7 +56,7 @@ func TestCompileLibrarySelection(t *testing.T) { }`) // - the second should use AnotherLibrary (because it was forced by --library) - stdout, _, err = cli.RunWithCustomEnv(vars, "compile", "-b", "arduino:avr:mega", "--library", anotherLib.String(), "--format", "json", sketch.String()) + stdout, _, err = cli.RunWithCustomEnv(vars, "compile", "-b", "arduino:avr:mega", "--library", anotherLib.String(), "--json", sketch.String()) require.NoError(t, err) requirejson.Contains(t, stdout, `{ "builder_result" : { diff --git a/internal/integrationtest/compile_4/compile_test.go b/internal/integrationtest/compile_4/compile_test.go index 63192a12774..a909cab3ab8 100644 --- a/internal/integrationtest/compile_4/compile_test.go +++ b/internal/integrationtest/compile_4/compile_test.go @@ -845,7 +845,7 @@ func tryBuild(t *testing.T, env *integrationtest.Environment, cli *integrationte args := []string{ "compile", "-b", fqbn, - "--format", "json", + "--json", options.Sketch.String()} if !options.NoTestLibraries { libsPath, err := paths.New("testdata", "libraries").Abs() diff --git a/internal/integrationtest/config/config_test.go b/internal/integrationtest/config/config_test.go index 91bb73af9f6..107141ccfb4 100644 --- a/internal/integrationtest/config/config_test.go +++ b/internal/integrationtest/config/config_test.go @@ -239,7 +239,7 @@ func TestDump(t *testing.T) { require.NoError(t, err) require.FileExists(t, configFile.String()) - stdout, _, err := cli.Run("config", "dump", "--config-file", configFile.String(), "--format", "json") + stdout, _, err := cli.Run("config", "dump", "--config-file", configFile.String(), "--json") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[]") @@ -249,7 +249,7 @@ func TestDump(t *testing.T) { require.Contains(t, string(stdout), configFile.String()) require.FileExists(t, configFile.String()) - stdout, _, err = cli.Run("config", "dump", "--format", "json") + stdout, _, err = cli.Run("config", "dump", "--json") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[\"https://example.com\"]") } @@ -265,7 +265,7 @@ func TestDumpWithConfigFileFlag(t *testing.T) { require.NoError(t, err) require.FileExists(t, configFile.String()) - stdout, _, err := cli.Run("config", "dump", "--config-file", configFile.String(), "--format", "json") + stdout, _, err := cli.Run("config", "dump", "--config-file", configFile.String(), "--json") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[\"https://example.com\"]") @@ -275,8 +275,7 @@ func TestDumpWithConfigFileFlag(t *testing.T) { "--config-file", configFile.String(), "--additional-urls=https://another-url.com", - "--format", - "json", + "--json", ) require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[\"https://another-url.com\"]") @@ -316,7 +315,7 @@ func TestAddSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies no additional urls are present - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[]") @@ -326,7 +325,7 @@ func TestAddSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies URL has been saved - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[\"https://example.com\"]") @@ -337,7 +336,7 @@ func TestAddSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies a second copy has NOT been added - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[\"https://example.com\"]") } @@ -351,7 +350,7 @@ func TestAddMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies no additional urls are present - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[]") @@ -366,7 +365,7 @@ func TestAddMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies URL has been saved - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls | length", "2") requirejson.Contains(t, stdout, ` @@ -386,7 +385,7 @@ func TestAddMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies no change in result array - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls | length", "2") requirejson.Contains(t, stdout, ` @@ -411,7 +410,7 @@ func TestAddMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies URL has been saved - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls | length", "3") requirejson.Contains(t, stdout, ` @@ -437,7 +436,7 @@ func TestAddOnUnsupportedKey(t *testing.T) { require.NoError(t, err) // Verifies default value - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .daemon | .port", "\"50051\"") @@ -447,7 +446,7 @@ func TestAddOnUnsupportedKey(t *testing.T) { require.Contains(t, string(stderr), "The key 'daemon.port' is not a list of items, can't add to it.\nMaybe use 'config set'?") // Verifies value is not changed - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .daemon | .port", "\"50051\"") } @@ -469,7 +468,7 @@ func TestRemoveSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies default state - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls | length", "2") requirejson.Contains(t, stdout, ` @@ -489,7 +488,7 @@ func TestRemoveSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies URLs has been removed - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[\"https://example.com/yet_another_package_example_index.json\"]") } @@ -511,7 +510,7 @@ func TestRemoveMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies default state - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls | length", "2") requirejson.Contains(t, stdout, ` @@ -531,7 +530,7 @@ func TestRemoveMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies all URLs have been removed - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[]") } @@ -545,7 +544,7 @@ func TestRemoveOnUnsupportedKey(t *testing.T) { require.NoError(t, err) // Verifies default value - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .daemon | .port", "\"50051\"") @@ -555,7 +554,7 @@ func TestRemoveOnUnsupportedKey(t *testing.T) { require.Contains(t, string(stderr), "The key 'daemon.port' is not a list of items, can't remove from it.\nMaybe use 'config delete'?") // Verifies value is not changed - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .daemon | .port", "\"50051\"") } @@ -569,7 +568,7 @@ func TestSetSliceWithSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies default state - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[]") @@ -579,7 +578,7 @@ func TestSetSliceWithSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies value is changed - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[\"https://example.com/package_example_index.json\"]") @@ -589,7 +588,7 @@ func TestSetSliceWithSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies value is changed - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[\"https://example.com/yet_another_package_example_index.json\"]") } @@ -603,7 +602,7 @@ func TestSetSliceWithMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies default state - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[]") @@ -616,7 +615,7 @@ func TestSetSliceWithMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies value is changed - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls | length", "2") requirejson.Contains(t, stdout, ` @@ -640,7 +639,7 @@ func TestSetSliceWithMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies previous value is overwritten - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls | length", "2") requirejson.Contains(t, stdout, ` @@ -672,7 +671,7 @@ func TestSetSliceWithMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies all unique values exist in config - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls | length", "4") requirejson.Contains(t, stdout, ` @@ -699,7 +698,7 @@ func TestSetStringWithSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies default state - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .logging | .level", "\"info\"") @@ -708,7 +707,7 @@ func TestSetStringWithSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies value is changed - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .logging | .level", "\"trace\"") } @@ -722,7 +721,7 @@ func TestSetStringWithMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies default state - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .logging | .level", "\"info\"") @@ -741,7 +740,7 @@ func TestSetBoolWithSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies default state - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .library | .enable_unsafe_install", "false") @@ -750,7 +749,7 @@ func TestSetBoolWithSingleArgument(t *testing.T) { require.NoError(t, err) // Verifies value is changed - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .library | .enable_unsafe_install", "true") } @@ -764,7 +763,7 @@ func TestSetBoolWithMultipleArguments(t *testing.T) { require.NoError(t, err) // Verifies default state - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .library | .enable_unsafe_install", "false") @@ -783,7 +782,7 @@ func TestDelete(t *testing.T) { require.NoError(t, err) // Verifies default state - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .library | .enable_unsafe_install", "false") @@ -800,7 +799,7 @@ func TestDelete(t *testing.T) { require.NotContains(t, configLines, "enable_unsafe_install") // Verifies default state - stdout, _, err = cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .board_manager | .additional_urls", "[]") @@ -827,22 +826,22 @@ func TestGet(t *testing.T) { require.NoError(t, err) // Verifies default state - stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Query(t, stdout, ".config | .daemon | .port", `"50051"`) // Get simple key value - stdout, _, err = cli.Run("config", "get", "daemon.port", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "get", "daemon.port", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Contains(t, stdout, `"50051"`) // Get structured key value - stdout, _, err = cli.Run("config", "get", "daemon", "--format", "json", "--config-file", "arduino-cli.yaml") + stdout, _, err = cli.Run("config", "get", "daemon", "--json", "--config-file", "arduino-cli.yaml") require.NoError(t, err) requirejson.Contains(t, stdout, `{"port":"50051"}`) // Get undefined key - _, stderr, err := cli.Run("config", "get", "foo", "--format", "json", "--config-file", "arduino-cli.yaml") + _, stderr, err := cli.Run("config", "get", "foo", "--json", "--config-file", "arduino-cli.yaml") require.Error(t, err) requirejson.Contains(t, stderr, `{"error":"Cannot get the configuration key foo: key not found in settings"}`) } @@ -857,23 +856,23 @@ func TestInitializationOrderOfConfigThroughFlagAndEnv(t *testing.T) { envConfig.WriteFile([]byte(`env-test: "test"`)) // No flag nor env specified. - stdout, _, err := cli.Run("config", "dump", "--format", "json") + stdout, _, err := cli.Run("config", "dump", "--json") require.NoError(t, err) requirejson.NotEmpty(t, stdout) // Flag specified - stdout, _, err = cli.Run("config", "dump", "--config-file", cliConfig.String(), "--format", "json") + stdout, _, err = cli.Run("config", "dump", "--config-file", cliConfig.String(), "--json") require.NoError(t, err) requirejson.Contains(t, stdout, `{"config":{ "cli-test": "test" }}`) // Env specified customEnv := map[string]string{"ARDUINO_CONFIG_FILE": envConfig.String()} - stdout, _, err = cli.RunWithCustomEnv(customEnv, "config", "dump", "--format", "json") + stdout, _, err = cli.RunWithCustomEnv(customEnv, "config", "dump", "--json") require.NoError(t, err) requirejson.Contains(t, stdout, `{"config":{ "env-test": "test" }}`) // Flag and env specified, flag takes precedence - stdout, _, err = cli.RunWithCustomEnv(customEnv, "config", "dump", "--config-file", cliConfig.String(), "--format", "json") + stdout, _, err = cli.RunWithCustomEnv(customEnv, "config", "dump", "--config-file", cliConfig.String(), "--json") require.NoError(t, err) requirejson.Contains(t, stdout, `{"config":{ "cli-test": "test" }}`) } diff --git a/internal/integrationtest/core/core_test.go b/internal/integrationtest/core/core_test.go index 1df21f22b79..864e45ab710 100644 --- a/internal/integrationtest/core/core_test.go +++ b/internal/integrationtest/core/core_test.go @@ -47,7 +47,7 @@ func TestCorrectHandlingOfPlatformVersionProperty(t *testing.T) { require.NoError(t, testPlatform.CopyDirTo(cli.SketchbookDir().Join("hardware", "DxCore-dev"))) // Trigger problematic call - out, _, err := cli.Run("core", "list", "--format", "json") + out, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Contains(t, out, `{ "platforms": [ @@ -83,19 +83,19 @@ func TestCoreSearch(t *testing.T) { _, _, err = cli.Run("core", "install", "arduino:avr@1.8.6") require.NoError(t, err) - out, _, err = cli.Run("core", "search", "avr", "--format", "json") + out, _, err = cli.Run("core", "search", "avr", "--json") require.NoError(t, err) requirejson.NotEmpty(t, out) // Verify that "installed_version" is set requirejson.Contains(t, out, `{"platforms":[{installed_version: "1.8.6"}]}`) // additional URL - out, _, err = cli.Run("core", "search", "test_core", "--format", "json", "--additional-urls="+url.String()) + out, _, err = cli.Run("core", "search", "test_core", "--json", "--additional-urls="+url.String()) require.NoError(t, err) requirejson.Query(t, out, `.platforms | length`, `1`) // show all versions - out, _, err = cli.Run("core", "search", "test_core", "--all", "--format", "json", "--additional-urls="+url.String()) + out, _, err = cli.Run("core", "search", "test_core", "--all", "--json", "--additional-urls="+url.String()) require.NoError(t, err) requirejson.Query(t, out, `.platforms.[].releases | length`, "3") @@ -105,30 +105,30 @@ func TestCoreSearch(t *testing.T) { } // Search all Retrokit platforms - out, _, err = cli.Run("core", "search", "retrokit", "--all", "--additional-urls="+url.String(), "--format", "json") + out, _, err = cli.Run("core", "search", "retrokit", "--all", "--additional-urls="+url.String(), "--json") require.NoError(t, err) checkPlatformIsInJSONOutput(out, "Retrokits-RK002:arm", "1.0.5") checkPlatformIsInJSONOutput(out, "Retrokits-RK002:arm", "1.0.6") // Search using Retrokit Package Maintainer - out, _, err = cli.Run("core", "search", "Retrokits-RK002", "--all", "--additional-urls="+url.String(), "--format", "json") + out, _, err = cli.Run("core", "search", "Retrokits-RK002", "--all", "--additional-urls="+url.String(), "--json") require.NoError(t, err) checkPlatformIsInJSONOutput(out, "Retrokits-RK002:arm", "1.0.5") checkPlatformIsInJSONOutput(out, "Retrokits-RK002:arm", "1.0.6") // Search using the Retrokit Platform name - out, _, err = cli.Run("core", "search", "rk002", "--all", "--additional-urls="+url.String(), "--format", "json") + out, _, err = cli.Run("core", "search", "rk002", "--all", "--additional-urls="+url.String(), "--json") require.NoError(t, err) checkPlatformIsInJSONOutput(out, "Retrokits-RK002:arm", "1.0.5") checkPlatformIsInJSONOutput(out, "Retrokits-RK002:arm", "1.0.6") // Search using board names - out, _, err = cli.Run("core", "search", "myboard", "--all", "--additional-urls="+url.String(), "--format", "json") + out, _, err = cli.Run("core", "search", "myboard", "--all", "--additional-urls="+url.String(), "--json") require.NoError(t, err) checkPlatformIsInJSONOutput(out, "Package:x86", "1.2.3") runSearch := func(searchArgs string, expectedIDs ...string) { - args := []string{"core", "search", "--format", "json"} + args := []string{"core", "search", "--json"} args = append(args, strings.Split(searchArgs, " ")...) out, _, err := cli.Run(args...) require.NoError(t, err) @@ -182,7 +182,7 @@ func TestCoreSearchNoArgs(t *testing.T) { numPlatforms := len(lines) - 1 // Same thing in JSON format, also check the number of platforms found is the same - stdout, _, err = cli.Run("core", "search", "--format", "json") + stdout, _, err = cli.Run("core", "search", "--json") require.NoError(t, err) requirejson.Contains(t, stdout, `{"platforms":[{"id": "test:x86", "releases": { "2.0.0": {"name":"test_core"}}}]}`) requirejson.Query(t, stdout, ".platforms | length", fmt.Sprint(numPlatforms)) @@ -200,7 +200,7 @@ func TestCoreSearchNoArgs(t *testing.T) { numPlatforms = len(lines) - 1 // same thing in JSON format, also check the number of platforms found is the same - stdout, _, err = cli.Run("core", "search", "--format", "json", "--additional-urls="+url.String()) + stdout, _, err = cli.Run("core", "search", "--json", "--additional-urls="+url.String()) require.NoError(t, err) requirejson.Contains(t, stdout, `{ "platforms": [ @@ -327,7 +327,7 @@ func TestCoreInstall(t *testing.T) { // Install a specific core version _, _, err = cli.Run("core", "install", "arduino:avr@1.6.16") require.NoError(t, err) - stdout, _, err := cli.Run("core", "list", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms.[] | select(.id == "arduino:avr") | .installed_version`, `"1.6.16"`) @@ -342,12 +342,12 @@ func TestCoreInstall(t *testing.T) { // Replace it with a more recent one without --no-overwrite (should succeed) _, _, err = cli.Run("core", "install", "arduino:avr@1.6.17") require.NoError(t, err) - stdout, _, err = cli.Run("core", "list", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms.[] | select(.id == "arduino:avr") | .installed_version`, `"1.6.17"`) // Confirm core is listed as "updatable" - stdout, _, err = cli.Run("core", "list", "--updatable", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--updatable", "--json") require.NoError(t, err) jsonout := requirejson.Parse(t, stdout) q := jsonout.Query(`.platforms.[] | select(.id == "arduino:avr")`) @@ -357,12 +357,12 @@ func TestCoreInstall(t *testing.T) { // Upgrade the core to latest version _, _, err = cli.Run("core", "upgrade", "arduino:avr") require.NoError(t, err) - stdout, _, err = cli.Run("core", "list", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms.[] | select(.id == "arduino:avr") | .installed_version`, latest.String()) // double check the core isn't updatable anymore - stdout, _, err = cli.Run("core", "list", "--updatable", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--updatable", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `0`) } @@ -375,12 +375,12 @@ func TestCoreUninstall(t *testing.T) { require.NoError(t, err) _, _, err = cli.Run("core", "install", "arduino:avr") require.NoError(t, err) - stdout, _, err := cli.Run("core", "list", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Contains(t, stdout, `{"platforms":[ { "id": "arduino:avr" } ]}`) _, _, err = cli.Run("core", "uninstall", "arduino:avr") require.NoError(t, err) - stdout, _, err = cli.Run("core", "list", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `0`) } @@ -445,7 +445,7 @@ func TestCoreUpdateWithLocalUrl(t *testing.T) { testIndex = "/" + strings.ReplaceAll(testIndex, "\\", "/") } - stdout, _, err := cli.Run("core", "update-index", "--additional-urls=file://"+testIndex, "--format", "json") + stdout, _, err := cli.Run("core", "update-index", "--additional-urls=file://"+testIndex, "--json") require.NoError(t, err) requirejson.Parse(t, stdout).MustContain(`{"updated_indexes":[{"index_url":"file://` + testIndex + `","status":"skipped"}]}`) } @@ -458,7 +458,7 @@ func TestCoreSearchManuallyInstalledCoresNotPrinted(t *testing.T) { require.NoError(t, err) // Verifies only cores in board manager are shown - stdout, _, err := cli.Run("core", "search", "--format", "json") + stdout, _, err := cli.Run("core", "search", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length > 0`, `true`) oldJson := stdout @@ -473,7 +473,7 @@ func TestCoreSearchManuallyInstalledCoresNotPrinted(t *testing.T) { require.NoError(t, err) // Verifies manually installed core is not shown - stdout, _, err = cli.Run("core", "search", "--format", "json") + stdout, _, err = cli.Run("core", "search", "--json") require.NoError(t, err) requirejson.NotContains(t, stdout, `{"platforms":[{"id": "arduino-beta-development:avr"}]}`) require.Equal(t, oldJson, stdout) @@ -487,7 +487,7 @@ func TestCoreListAllManuallyInstalledCore(t *testing.T) { require.NoError(t, err) // Verifies only cores in board manager are shown - stdout, _, err := cli.Run("core", "list", "--all", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--all", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length > 0`, `true`) length, err := strconv.Atoi(requirejson.Parse(t, stdout).Query(".platforms | length").String()) @@ -503,7 +503,7 @@ func TestCoreListAllManuallyInstalledCore(t *testing.T) { require.NoError(t, err) // Verifies manually installed core is shown - stdout, _, err = cli.Run("core", "list", "--all", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--all", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, fmt.Sprint(length+1)) requirejson.Contains(t, stdout, `{"platforms":[ @@ -527,7 +527,7 @@ func TestCoreListShowsLatestVersionWhenMultipleReleasesOfAManuallyInstalledCoreA require.NoError(t, err) // Verifies only cores in board manager are shown - stdout, _, err := cli.Run("core", "list", "--all", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--all", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length > 0`, `true`) length, err := strconv.Atoi(requirejson.Parse(t, stdout).Query(".platforms | length").String()) @@ -553,7 +553,7 @@ func TestCoreListShowsLatestVersionWhenMultipleReleasesOfAManuallyInstalledCoreA require.NoError(t, err) // When manually installing 2 releases of the same core, the newest one takes precedence - stdout, _, err = cli.Run("core", "list", "--all", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--all", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, fmt.Sprint(length+1)) requirejson.Contains(t, stdout, `{"platforms":[ @@ -581,7 +581,7 @@ func TestCoreListUpdatableAllFlags(t *testing.T) { require.NoError(t, err) // Verifies only cores in board manager are shown - stdout, _, err := cli.Run("core", "list", "--all", "--updatable", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--all", "--updatable", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length > 0`, `true`) length, err := strconv.Atoi(requirejson.Parse(t, stdout).Query(".platforms | length").String()) @@ -597,7 +597,7 @@ func TestCoreListUpdatableAllFlags(t *testing.T) { require.NoError(t, err) // Verifies using both --updatable and --all flags --all takes precedence - stdout, _, err = cli.Run("core", "list", "--all", "--updatable", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--all", "--updatable", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, fmt.Sprint(length+1)) requirejson.Contains(t, stdout, `{"platforms":[ @@ -674,7 +674,7 @@ func TestCoreListWithInstalledJson(t *testing.T) { require.NoError(t, err) // Verifies installed core is correctly found and name is set - stdout, _, err := cli.Run("core", "list", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `1`) requirejson.Contains(t, stdout, `{"platforms":[ @@ -697,7 +697,7 @@ func TestCoreListWithInstalledJson(t *testing.T) { require.NoError(t, installedJson.Remove()) // Verifies installed core is still found and name is set - stdout, _, err = cli.Run("core", "list", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `1`) // Name for this core changes since if there's installed.json file we read it from @@ -790,7 +790,7 @@ func TestCoreSearchSortedResults(t *testing.T) { require.Equal(t, lines, append(notDeprecated, deprecated...)) // test same behaviour with json output - stdout, _, err = cli.Run("core", "search", "--additional-urls="+url.String(), "--format=json") + stdout, _, err = cli.Run("core", "search", "--additional-urls="+url.String(), "--json") require.NoError(t, err) // verify that results are already sorted correctly @@ -861,7 +861,7 @@ func TestCoreListSortedResults(t *testing.T) { require.Equal(t, lines, append(notDeprecated, deprecated...)) // test same behaviour with json output - stdout, _, err = cli.Run("core", "list", "--additional-urls="+url.String(), "--format=json") + stdout, _, err = cli.Run("core", "list", "--additional-urls="+url.String(), "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `3`) @@ -908,7 +908,7 @@ func TestCoreListDeprecatedPlatformWithInstalledJson(t *testing.T) { require.NoError(t, installedJsonFile.WriteFile([]byte(updatedInstalledJsonData))) // test same behaviour with json output - stdout, _, err := cli.Run("core", "list", "--additional-urls="+url.String(), "--format=json") + stdout, _, err := cli.Run("core", "list", "--additional-urls="+url.String(), "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `1`) @@ -922,7 +922,7 @@ func TestCoreListPlatformWithoutPlatformTxt(t *testing.T) { _, _, err := cli.Run("update") require.NoError(t, err) - stdout, _, err := cli.Run("core", "list", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `0`) @@ -934,7 +934,7 @@ func TestCoreListPlatformWithoutPlatformTxt(t *testing.T) { require.NoError(t, testBoardsTxt.CopyTo(boardsTxt)) // Verifies no core is installed - stdout, _, err = cli.Run("core", "list", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `1`) requirejson.Query(t, stdout, ".platforms.[] | .id", `"some-packager:some-arch"`) @@ -954,7 +954,7 @@ func TestCoreDownloadMultiplePlatforms(t *testing.T) { require.NoError(t, err) // Verifies no core is installed - stdout, _, err := cli.Run("core", "list", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `0`) @@ -970,7 +970,7 @@ func TestCoreDownloadMultiplePlatforms(t *testing.T) { require.NoError(t, testBoardsTxt.CopyTo(boardsTxt1)) // Verifies the two cores are detected - stdout, _, err = cli.Run("core", "list", "--format", "json") + stdout, _, err = cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `2`) @@ -994,7 +994,7 @@ func TestCoreWithMissingCustomBoardOptionsIsLoaded(t *testing.T) { _, _, err := cli.Run("update") require.NoError(t, err) - stdout, _, err := cli.Run("core", "list", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `1`) // Verifies platform is loaded except excluding board with missing options @@ -1032,7 +1032,7 @@ func TestCoreListOutdatedCore(t *testing.T) { _, _, err = cli.Run("core", "install", "arduino:samd@1.8.6") require.NoError(t, err) - stdout, _, err := cli.Run("core", "list", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `1`) requirejson.Query(t, stdout, ".platforms.[0] | .installed_version", "\"1.8.6\"") @@ -1051,7 +1051,7 @@ func TestCoreLoadingPackageManager(t *testing.T) { // Create empty architecture folder (this condition is normally produced by `core uninstall`) require.NoError(t, cli.DataDir().Join("packages", "foovendor", "hardware", "fooarch").MkdirAll()) - _, _, err := cli.Run("core", "list", "--all", "--format", "json") + _, _, err := cli.Run("core", "list", "--all", "--json") require.NoError(t, err) // this should not make the cli crash } @@ -1152,7 +1152,7 @@ func TestCoreUpgradeWarningWithPackageInstalledButNotIndexed(t *testing.T) { _, _, err = cli.Run("core", "install", "test:x86@1.0.0", "--additional-urls="+url) require.NoError(t, err) // upgrade without index fires a warning - jsonStdout, _, _ := cli.Run("core", "upgrade", "test:x86", "--format", "json") + jsonStdout, _, _ := cli.Run("core", "upgrade", "test:x86", "--json") requirejson.Query(t, jsonStdout, ".warnings[]", `"missing package index for test:x86, future updates cannot be guaranteed"`) }) @@ -1161,7 +1161,7 @@ func TestCoreUpgradeWarningWithPackageInstalledButNotIndexed(t *testing.T) { require.NoError(t, os.Remove(installedJson.String())) t.Run("missing both installed.json and additional-urls", func(t *testing.T) { - jsonStdout, _, _ := cli.Run("core", "upgrade", "test:x86", "--format", "json") + jsonStdout, _, _ := cli.Run("core", "upgrade", "test:x86", "--json") requirejson.Query(t, jsonStdout, ".warnings[]", `"missing package index for test:x86, future updates cannot be guaranteed"`) }) } @@ -1170,7 +1170,7 @@ func TestCoreListWhenNoPlatformAreInstalled(t *testing.T) { env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) defer env.CleanUp() - stdout, _, err := cli.Run("core", "list", "--format", "json") + stdout, _, err := cli.Run("core", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | length`, `0`) @@ -1190,7 +1190,7 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) { require.NoError(t, err) // the `latest_version` must point to an installable release. In the releases field the latest entry, points to an incompatible version. - stdout, _, err := cli.Run("core", "list", "--all", "--format", "json", additionalURLs) + stdout, _, err := cli.Run("core", "list", "--all", "--json", additionalURLs) require.NoError(t, err) requirejson.Parse(t, stdout). Query(`.platforms | .[] | select(.id == "foo_vendor:avr")`). @@ -1207,7 +1207,7 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) { // install latest compatible version _, _, err = cli.Run("core", "install", "foo_vendor:avr", additionalURLs) require.NoError(t, err) - stdout, _, err = cli.Run("core", "list", "--all", "--format", "json", additionalURLs) + stdout, _, err = cli.Run("core", "list", "--all", "--json", additionalURLs) require.NoError(t, err) requirejson.Parse(t, stdout). Query(`.platforms | .[] | select(.id == "foo_vendor:avr")`). @@ -1225,39 +1225,39 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) { // install a specific compatible version _, _, err = cli.Run("core", "install", "foo_vendor:avr@1.0.0", additionalURLs) require.NoError(t, err) - stdout, _, err = cli.Run("core", "list", "--format", "json", additionalURLs) + stdout, _, err = cli.Run("core", "list", "--json", additionalURLs) require.NoError(t, err) requirejson.Parse(t, stdout). Query(`.platforms | .[] | select(.id == "foo_vendor:avr")`). MustContain(`{"installed_version": "1.0.0", "releases": {"1.0.0": {"compatible": true}}}`) // Lists all updatable cores - stdout, _, err = cli.Run("core", "list", "--updatable", "--format", "json", additionalURLs) + stdout, _, err = cli.Run("core", "list", "--updatable", "--json", additionalURLs) require.NoError(t, err) requirejson.Parse(t, stdout). Query(`.platforms | .[] | select(.id == "foo_vendor:avr")`). MustContain(`{"latest_version": "1.0.1", "releases": {"1.0.1": {"compatible": true}}}`) // Show outdated cores, must show latest compatible - stdout, _, err = cli.Run("outdated", "--format", "json", additionalURLs) + stdout, _, err = cli.Run("outdated", "--json", additionalURLs) require.NoError(t, err) requirejson.Parse(t, stdout). Query(`.platforms | .[] | select(.id == "foo_vendor:avr")`). MustContain(`{"latest_version": "1.0.1", "releases":{"1.0.1": {"compatible": true}}}`) // upgrade to latest compatible (1.0.0 -> 1.0.1) - _, _, err = cli.Run("core", "upgrade", "foo_vendor:avr", "--format", "json", additionalURLs) + _, _, err = cli.Run("core", "upgrade", "foo_vendor:avr", "--json", additionalURLs) require.NoError(t, err) - stdout, _, err = cli.Run("core", "list", "--format", "json", additionalURLs) + stdout, _, err = cli.Run("core", "list", "--json", additionalURLs) require.NoError(t, err) requirejson.Parse(t, stdout). Query(`.platforms | .[] | select(.id == "foo_vendor:avr") | .releases[.installed_version]`). MustContain(`{"version": "1.0.1", "compatible": true}`) // upgrade to latest incompatible not possible (1.0.1 -> 1.0.2) - _, _, err = cli.Run("core", "upgrade", "foo_vendor:avr", "--format", "json", additionalURLs) + _, _, err = cli.Run("core", "upgrade", "foo_vendor:avr", "--json", additionalURLs) require.NoError(t, err) - stdout, _, err = cli.Run("core", "list", "--format", "json", additionalURLs) + stdout, _, err = cli.Run("core", "list", "--json", additionalURLs) require.NoError(t, err) requirejson.Query(t, stdout, `.platforms | .[] | select(.id == "foo_vendor:avr") | .installed_version`, `"1.0.1"`) @@ -1270,9 +1270,9 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) { // Core search { // core search with and without --all produces the same results. - stdoutSearchAll, _, err := cli.Run("core", "search", "--all", "--format", "json", additionalURLs) + stdoutSearchAll, _, err := cli.Run("core", "search", "--all", "--json", additionalURLs) require.NoError(t, err) - stdoutSearch, _, err := cli.Run("core", "search", "--format", "json", additionalURLs) + stdoutSearch, _, err := cli.Run("core", "search", "--json", additionalURLs) require.NoError(t, err) require.Equal(t, stdoutSearchAll, stdoutSearch) for _, stdout := range [][]byte{stdoutSearchAll, stdoutSearch} { diff --git a/internal/integrationtest/debug/debug_test.go b/internal/integrationtest/debug/debug_test.go index ffb95766b22..e298d8e2fbf 100644 --- a/internal/integrationtest/debug/debug_test.go +++ b/internal/integrationtest/debug/debug_test.go @@ -109,12 +109,12 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli require.NoError(t, err) // Build sketch - _, _, err = cli.Run("compile", "-b", "my:samd:my", sketchPath.String(), "--format", "json") + _, _, err = cli.Run("compile", "-b", "my:samd:my", sketchPath.String(), "--json") require.NoError(t, err) { // Starts debugger - jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my", "-P", "atmel_ice", sketchPath.String(), "--info", "--format", "json") + jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my", "-P", "atmel_ice", sketchPath.String(), "--info", "--json") require.NoError(t, err) debugOut := requirejson.Parse(t, jsonDebugOut) debugOut.MustContain(` @@ -172,7 +172,7 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli // Starts debugger with another programmer { - jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my", "-P", "my_cold_ice", sketchPath.String(), "--info", "--format", "json") + jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my", "-P", "my_cold_ice", sketchPath.String(), "--info", "--json") require.NoError(t, err) debugOut := requirejson.Parse(t, jsonDebugOut) debugOut.MustContain(` @@ -229,7 +229,7 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli { // Starts debugger with an old-style openocd script definition - jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my2", "-P", "atmel_ice", sketchPath.String(), "--info", "--format", "json") + jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my2", "-P", "atmel_ice", sketchPath.String(), "--info", "--json") require.NoError(t, err) debugOut := requirejson.Parse(t, jsonDebugOut) debugOut.MustContain(` @@ -253,7 +253,7 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli { // Starts debugger with mixed old and new-style openocd script definition - jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my2", "-P", "my_cold_ice", sketchPath.String(), "--info", "--format", "json") + jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my2", "-P", "my_cold_ice", sketchPath.String(), "--info", "--json") require.NoError(t, err) debugOut := requirejson.Parse(t, jsonDebugOut) debugOut.MustContain(` @@ -277,7 +277,7 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli { // Mixing programmer and additional_config - jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my3", "-P", "my_cold_ice", sketchPath.String(), "--info", "--format", "json") + jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my3", "-P", "my_cold_ice", sketchPath.String(), "--info", "--json") require.NoError(t, err) debugOut := requirejson.Parse(t, jsonDebugOut) debugOut.MustContain(` @@ -306,7 +306,7 @@ func testAllDebugInformation(t *testing.T, env *integrationtest.Environment, cli { // Mixing programmer and additional_config selected by another variable - jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my4", "-P", "my_cold_ice", sketchPath.String(), "--info", "--format", "json") + jsonDebugOut, _, err := cli.Run("debug", "-b", "my:samd:my4", "-P", "my_cold_ice", sketchPath.String(), "--info", "--json") require.NoError(t, err) debugOut := requirejson.Parse(t, jsonDebugOut) debugOut.MustContain(` @@ -340,7 +340,7 @@ func testDebugCheck(t *testing.T, env *integrationtest.Environment, cli *integra require.NoError(t, err) require.Contains(t, string(out), "The given board/programmer configuration supports debugging.") - out, _, err = cli.Run("debug", "check", "-b", "arduino:samd:mkr1000", "-P", "atmel_ice", "--format", "json") + out, _, err = cli.Run("debug", "check", "-b", "arduino:samd:mkr1000", "-P", "atmel_ice", "--json") require.NoError(t, err) requirejson.Query(t, out, `.debugging_supported`, `true`) @@ -348,28 +348,28 @@ func testDebugCheck(t *testing.T, env *integrationtest.Environment, cli *integra require.NoError(t, err) require.Contains(t, string(out), "The given board/programmer configuration does NOT support debugging.") - out, _, err = cli.Run("debug", "check", "-b", "arduino:avr:uno", "-P", "atmel_ice", "--format", "json") + out, _, err = cli.Run("debug", "check", "-b", "arduino:avr:uno", "-P", "atmel_ice", "--json") require.NoError(t, err) requirejson.Query(t, out, `.debugging_supported`, `false`) // Test minimum FQBN compute - out, _, err = cli.Run("debug", "check", "-b", "my:samd:my5", "-P", "atmel_ice", "--format", "json") + out, _, err = cli.Run("debug", "check", "-b", "my:samd:my5", "-P", "atmel_ice", "--json") require.NoError(t, err) requirejson.Contains(t, out, `{ "debugging_supported" : false }`) - out, _, err = cli.Run("debug", "check", "-b", "my:samd:my5:dbg=on", "-P", "atmel_ice", "--format", "json") + out, _, err = cli.Run("debug", "check", "-b", "my:samd:my5:dbg=on", "-P", "atmel_ice", "--json") require.NoError(t, err) requirejson.Contains(t, out, `{ "debugging_supported" : true, "debug_fqbn" : "my:samd:my5:dbg=on" }`) - out, _, err = cli.Run("debug", "check", "-b", "my:samd:my5:dbg=on,cpu=150m", "-P", "atmel_ice", "--format", "json") + out, _, err = cli.Run("debug", "check", "-b", "my:samd:my5:dbg=on,cpu=150m", "-P", "atmel_ice", "--json") require.NoError(t, err) requirejson.Contains(t, out, `{ "debugging_supported" : true, "debug_fqbn" : "my:samd:my5:dbg=on" }`) - out, _, err = cli.Run("debug", "check", "-b", "my:samd:my6", "-P", "atmel_ice", "--format", "json") + out, _, err = cli.Run("debug", "check", "-b", "my:samd:my6", "-P", "atmel_ice", "--json") require.NoError(t, err) requirejson.Contains(t, out, `{ "debugging_supported" : true, "debug_fqbn" : "my:samd:my6" }`) - out, _, err = cli.Run("debug", "check", "-b", "my:samd:my6:dbg=on", "-P", "atmel_ice", "--format", "json") + out, _, err = cli.Run("debug", "check", "-b", "my:samd:my6:dbg=on", "-P", "atmel_ice", "--json") require.NoError(t, err) requirejson.Contains(t, out, `{ "debugging_supported" : true, "debug_fqbn" : "my:samd:my6" }`) } diff --git a/internal/integrationtest/lib/lib_test.go b/internal/integrationtest/lib/lib_test.go index 115a3550964..ab49a35e2a7 100644 --- a/internal/integrationtest/lib/lib_test.go +++ b/internal/integrationtest/lib/lib_test.go @@ -55,13 +55,13 @@ func TestLibUpgradeCommand(t *testing.T) { // Test upgrade of installed library _, _, err = cli.Run("lib", "install", "Servo@1.1.6") require.NoError(t, err) - stdOut, _, err := cli.Run("lib", "list", "--format", "json") + stdOut, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Contains(t, stdOut, `{"installed_libraries": [ { "library":{ "name":"Servo", "version": "1.1.6" } } ]}`) _, _, err = cli.Run("lib", "upgrade", "Servo") require.NoError(t, err) - stdOut, _, err = cli.Run("lib", "list", "--format", "json") + stdOut, _, err = cli.Run("lib", "list", "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, stdOut) jsonOut.MustNotContain(`{"installed_libraries": [{"library":{ "name":"Servo", "version": "1.1.6" }}]}`) @@ -70,7 +70,7 @@ func TestLibUpgradeCommand(t *testing.T) { // Upgrade of already up-to-date library _, _, err = cli.Run("lib", "upgrade", "Servo") require.NoError(t, err) - stdOut, _, err = cli.Run("lib", "list", "--format", "json") + stdOut, _, err = cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdOut, `.installed_libraries.[].library | select(.name=="Servo") | .version`, servoVersion) } @@ -82,11 +82,11 @@ func TestLibCommandsUsingNameInsteadOfDirName(t *testing.T) { _, _, err := cli.Run("lib", "install", "Robot Motor") require.NoError(t, err) - jsonOut, _, err := cli.Run("lib", "examples", "Robot Motor", "--format", "json") + jsonOut, _, err := cli.Run("lib", "examples", "Robot Motor", "--json") require.NoError(t, err) requirejson.Len(t, jsonOut, 1, "Library 'Robot Motor' not matched in lib examples command.") - jsonOut, _, err = cli.Run("lib", "list", "Robot Motor", "--format", "json") + jsonOut, _, err = cli.Run("lib", "list", "Robot Motor", "--json") require.NoError(t, err) requirejson.Len(t, jsonOut, 1, "Library 'Robot Motor' not matched in lib list command.") } @@ -103,7 +103,7 @@ func TestLibInstallMultipleSameLibrary(t *testing.T) { require.NoError(t, err) _, _, err = cli.Run("lib", "install", "Arduino SigFox for MKRFox1200") require.NoError(t, err) - jsonOut, _, err := cli.Run("lib", "list", "--format", "json") + jsonOut, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) // Count how many libraries with the name "Arduino SigFox for MKRFox1200" are installed requirejson.Parse(t, jsonOut). @@ -118,7 +118,7 @@ func TestLibInstallMultipleSameLibrary(t *testing.T) { require.NoError(t, err) _, _, err = cli.Run("lib", "upgrade", "Arduino SigFox for MKRFox1200") require.NoError(t, err) - jsonOut, _, err = cli.Run("lib", "list", "--format", "json") + jsonOut, _, err = cli.Run("lib", "list", "--json") require.NoError(t, err) // Count how many libraries with the name "Arduino SigFox for MKRFox1200" are installed requirejson.Parse(t, jsonOut). @@ -138,7 +138,7 @@ func TestDuplicateLibInstallDetection(t *testing.T) { otaLibPath := cli.SketchbookDir().Join("libraries", "ArduinoOTA") err = otaLibPath.CopyDirTo(otaLibPath.Parent().Join("CopyOfArduinoOTA")) require.NoError(t, err) - jsonOut, _, err := cli.Run("lib", "list", "--format", "json") + jsonOut, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, jsonOut, `.installed_libraries | length`, `2`, "Duplicate library install is not detected by the CLI") @@ -166,7 +166,7 @@ func TestDuplicateLibInstallFromGitDetection(t *testing.T) { _, _, err = cli.RunWithCustomEnv(cliEnv, "lib", "install", "--git-url", "https://github.com/arduino-libraries/SigFox#1.0.3") require.NoError(t, err) - jsonOut, _, err := cli.Run("lib", "list", "--format", "json") + jsonOut, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) // Count how many libraries with the name "Arduino SigFox for MKRFox1200" are installed requirejson.Parse(t, jsonOut). @@ -178,7 +178,7 @@ func TestDuplicateLibInstallFromGitDetection(t *testing.T) { require.NoError(t, err) // Check if double install happened - jsonOut, _, err = cli.Run("lib", "list", "--format", "json") + jsonOut, _, err = cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Parse(t, jsonOut). Query(`[.installed_libraries.[].library.name | select(. == "Arduino SigFox for MKRFox1200")]`). @@ -203,7 +203,7 @@ func TestDuplicateLibInstallFromGitDetection(t *testing.T) { require.NoError(t, err) // Check if double install happened - jsonOut, _, err = cli.Run("lib", "list", "--format", "json") + jsonOut, _, err = cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Parse(t, jsonOut). Query(`[.installed_libraries.[].library.name | select(. == "Arduino SigFox for MKRFox1200")]`). @@ -242,7 +242,7 @@ func TestLibDepsOutput(t *testing.T) { require.Regexp(t, `^✕ MKRWAN \d+\.\d+\.\d+ must be installed\.$`, lines[5]) require.Regexp(t, `^✕ WiFi101 \d+\.\d+\.\d+ must be installed\.$`, lines[6]) - stdOut, _, err = cli.Run("lib", "deps", "Arduino_ConnectionHandler@0.6.6", "--format", "json") + stdOut, _, err = cli.Run("lib", "deps", "Arduino_ConnectionHandler@0.6.6", "--json") require.NoError(t, err) var jsonDeps struct { @@ -284,7 +284,7 @@ func TestUpgradeLibraryWithDependencies(t *testing.T) { // Install library _, _, err = cli.Run("lib", "install", "Arduino_ConnectionHandler@0.3.3") require.NoError(t, err) - stdOut, _, err := cli.Run("lib", "deps", "Arduino_ConnectionHandler@0.3.3", "--format", "json") + stdOut, _, err := cli.Run("lib", "deps", "Arduino_ConnectionHandler@0.3.3", "--json") require.NoError(t, err) var jsonDeps struct { @@ -308,7 +308,7 @@ func TestUpgradeLibraryWithDependencies(t *testing.T) { // Test lib upgrade also install new dependencies of already installed library _, _, err = cli.Run("lib", "upgrade", "Arduino_ConnectionHandler") require.NoError(t, err) - stdOut, _, err = cli.Run("lib", "deps", "Arduino_ConnectionHandler", "--format", "json") + stdOut, _, err = cli.Run("lib", "deps", "Arduino_ConnectionHandler", "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, stdOut) @@ -329,7 +329,7 @@ func TestList(t *testing.T) { require.NoError(t, err) require.Empty(t, stderr) require.Contains(t, string(stdout), "No libraries installed.") - stdout, stderr, err = cli.Run("lib", "list", "--format", "json") + stdout, stderr, err = cli.Run("lib", "list", "--json") require.NoError(t, err) require.Empty(t, stderr) requirejson.Query(t, stdout, `.installed_libraries | length`, `0`) @@ -355,7 +355,7 @@ func TestList(t *testing.T) { require.Contains(t, toks[4], "An efficient and elegant JSON library...") // Look at the JSON output - stdout, stderr, err = cli.Run("lib", "list", "--format", "json") + stdout, stderr, err = cli.Run("lib", "list", "--json") require.NoError(t, err) require.Empty(t, stderr) requirejson.Query(t, stdout, `.installed_libraries | length`, `1`) @@ -366,7 +366,7 @@ func TestList(t *testing.T) { _, _, err = cli.Run("lib", "install", "Arduino_APDS9960@1.0.3") require.NoError(t, err) // Look at the JSON output - stdout, stderr, err = cli.Run("lib", "list", "Arduino_APDS9960", "--format", "json") + stdout, stderr, err = cli.Run("lib", "list", "Arduino_APDS9960", "--json") require.NoError(t, err) require.Empty(t, stderr) requirejson.Query(t, stdout, `.installed_libraries | length`, `1`) @@ -448,7 +448,7 @@ func TestListWithFqbn(t *testing.T) { require.Equal(t, "ArduinoJson", toks[0]) // Look at the JSON output - stdout, stderr, err = cli.Run("lib", "list", "-b", "arduino:avr:uno", "--format", "json") + stdout, stderr, err = cli.Run("lib", "list", "-b", "arduino:avr:uno", "--json") require.NoError(t, err) require.Empty(t, stderr) requirejson.Query(t, stdout, `.installed_libraries | length`, `6`) @@ -477,7 +477,7 @@ func TestListProvidesIncludesFallback(t *testing.T) { require.NoError(t, err) // List all libraries, even the ones installed with the above core - stdout, stderr, err := cli.Run("lib", "list", "--all", "--fqbn", "arduino:avr:uno", "--format", "json") + stdout, stderr, err := cli.Run("lib", "list", "--all", "--fqbn", "arduino:avr:uno", "--json") require.NoError(t, err) require.Empty(t, stderr) @@ -546,7 +546,7 @@ func TestInstall(t *testing.T) { // https://github.com/arduino/arduino-cli/issues/1727 _, _, err = cli.Run("lib", "install", "ILI9341_t3@1.0") require.NoError(t, err) - stdout, _, err := cli.Run("lib", "list", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Parse(t, stdout).Query(`.installed_libraries.[] | select(.library.name == "ILI9341_t3") | .library.version`).MustEqual(`"1.0"`) _, _, err = cli.Run("lib", "install", "ILI9341_t3@1") @@ -563,7 +563,7 @@ func TestInstallLibraryWithDependencies(t *testing.T) { require.NoError(t, err) // Verifies libraries are not installed - stdout, _, err := cli.Run("lib", "list", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `0`) @@ -572,7 +572,7 @@ func TestInstallLibraryWithDependencies(t *testing.T) { require.NoError(t, err) // Verifies library's dependencies are correctly installed - stdout, _, err = cli.Run("lib", "list", "--format", "json") + stdout, _, err = cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `[.installed_libraries.[] | .library | .name ] | sort`, `["MD_MAX72XX","MD_Parola"]`) @@ -603,7 +603,7 @@ func TestInstallNoDeps(t *testing.T) { require.NoError(t, err) // Verifies libraries are not installed - stdout, _, err := cli.Run("lib", "list", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `0`) @@ -612,7 +612,7 @@ func TestInstallNoDeps(t *testing.T) { require.NoError(t, err) // Verifies library's dependencies are not installed - stdout, _, err = cli.Run("lib", "list", "--format", "json") + stdout, _, err = cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries.[] | .library | .name`, `"MD_Parola"`) } @@ -712,7 +712,7 @@ func TestUninstallSpaces(t *testing.T) { require.NoError(t, err) _, _, err = cli.Run("lib", "uninstall", key) require.NoError(t, err) - stdout, _, err := cli.Run("lib", "list", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `0`) } @@ -740,7 +740,7 @@ func TestLibOpsCaseInsensitive(t *testing.T) { require.NoError(t, err) _, _, err = cli.Run("lib", "uninstall", key) require.NoError(t, err) - stdout, _, err := cli.Run("lib", "list", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `0`) } @@ -763,12 +763,12 @@ func TestSearch(t *testing.T) { expected := []string{"WiFi101", "WiFi101OTA", "Firebase Arduino based on WiFi101", "WiFi101_Generic"} require.Subset(t, libs, expected) - stdout, _, err = cli.Run("lib", "search", "--names", "--format", "json") + stdout, _, err = cli.Run("lib", "search", "--names", "--json") require.NoError(t, err) requirejson.Query(t, stdout, ".libraries | length", fmt.Sprint(len(libs))) runSearch := func(args string, expectedLibs []string) { - stdout, _, err = cli.Run("lib", "search", "--names", "--format", "json", args) + stdout, _, err = cli.Run("lib", "search", "--names", "--json", args) require.NoError(t, err) libraries := requirejson.Parse(t, stdout).Query("[ .libraries | .[] | .name ]").String() for _, l := range expectedLibs { @@ -795,7 +795,7 @@ func TestQualifiedSearch(t *testing.T) { defer env.CleanUp() runSearch := func(args string, expectedLibs []string) { - stdout, _, err := cli.Run("lib", "search", "--names", "--format", "json", args) + stdout, _, err := cli.Run("lib", "search", "--names", "--json", args) require.NoError(t, err) libraries := requirejson.Parse(t, stdout).Query("[ .libraries | .[] | .name ]").String() for _, l := range expectedLibs { @@ -821,7 +821,7 @@ func TestSearchParagraph(t *testing.T) { // within the index file. _, _, err := cli.Run("lib", "update-index") require.NoError(t, err) - stdout, _, err := cli.Run("lib", "search", "A simple and efficient JSON library", "--names", "--format", "json") + stdout, _, err := cli.Run("lib", "search", "A simple and efficient JSON library", "--names", "--json") require.NoError(t, err) requirejson.Contains(t, stdout, `{ "libraries": [ @@ -846,7 +846,7 @@ func TestLibListWithUpdatableFlag(t *testing.T) { require.Empty(t, stderr) require.Contains(t, string(stdout), "No libraries update is available.") // No library to update in json - stdout, stderr, err = cli.Run("lib", "list", "--updatable", "--format", "json") + stdout, stderr, err = cli.Run("lib", "list", "--updatable", "--json") require.NoError(t, err) require.Empty(t, stderr) requirejson.Query(t, stdout, `.installed_libraries | length`, `0`) @@ -876,7 +876,7 @@ func TestLibListWithUpdatableFlag(t *testing.T) { require.Equal(t, "An efficient and elegant JSON library...", lines[1][4]) // Look at the JSON output - stdout, stderr, err = cli.Run("lib", "list", "--updatable", "--format", "json") + stdout, stderr, err = cli.Run("lib", "list", "--updatable", "--json") require.NoError(t, err) require.Empty(t, stderr) requirejson.Query(t, stdout, `.installed_libraries | length`, `1`) @@ -1041,7 +1041,7 @@ func TestLibExamples(t *testing.T) { _, _, err = cli.Run("lib", "install", "Arduino_JSON@0.1.0") require.NoError(t, err) - stdout, _, err := cli.Run("lib", "examples", "Arduino_JSON", "--format", "json") + stdout, _, err := cli.Run("lib", "examples", "Arduino_JSON", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.examples | length`, `1`) examples := requirejson.Parse(t, stdout).Query(".examples.[0] | .examples").String() @@ -1061,7 +1061,7 @@ func TestLibExamplesWithPdeFile(t *testing.T) { _, _, err = cli.Run("lib", "install", "Encoder@1.4.1") require.NoError(t, err) - stdout, _, err := cli.Run("lib", "examples", "Encoder", "--format", "json") + stdout, _, err := cli.Run("lib", "examples", "Encoder", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.examples | length`, `1`) examples := requirejson.Parse(t, stdout).Query(".examples.[0] | .examples").String() @@ -1082,7 +1082,7 @@ func TestLibExamplesWithCaseMismatch(t *testing.T) { _, _, err = cli.Run("lib", "install", "WiFiManager@2.0.3-alpha") require.NoError(t, err) - stdout, _, err := cli.Run("lib", "examples", "WiFiManager", "--format", "json") + stdout, _, err := cli.Run("lib", "examples", "WiFiManager", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.examples | length`, `1`) requirejson.Query(t, stdout, ".examples.[0] | .examples | length", "14") @@ -1122,7 +1122,7 @@ func TestLibCommandsWithLibraryHavingInvalidVersion(t *testing.T) { require.NoError(t, err) // Verifies library is correctly returned - stdout, _, err := cli.Run("lib", "list", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `1`) requirejson.Query(t, stdout, ".installed_libraries.[0] | .library | .version", `"0.16.1"`) @@ -1133,7 +1133,7 @@ func TestLibCommandsWithLibraryHavingInvalidVersion(t *testing.T) { require.NoError(t, libPath.WriteFile([]byte("name=WiFi101\nversion=1.0001"))) // Verifies version is now empty - stdout, _, err = cli.Run("lib", "list", "--format", "json") + stdout, _, err = cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `1`) requirejson.Query(t, stdout, ".installed_libraries.[0] | .library | .version", "null") @@ -1143,7 +1143,7 @@ func TestLibCommandsWithLibraryHavingInvalidVersion(t *testing.T) { require.NoError(t, err) // Verifies library has been updated - stdout, _, err = cli.Run("lib", "list", "--format", "json") + stdout, _, err = cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `1`) requirejson.Query(t, stdout, ".installed_libraries.[0] | .library | .version != \"\"", "true") @@ -1301,7 +1301,7 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibrariesInSketchbook(t *testing.T _, _, err = cli.Run("lib", "install", "USBHost") require.NoError(t, err) - stdout, _, err := cli.Run("lib", "list", "--all", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--all", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `2`) // Verify both libraries have the same name @@ -1333,7 +1333,7 @@ func TestUpgradeDoesNotTryToUpgradeBundledCoreLibraries(t *testing.T) { _, _, err = cli.Run("lib", "install", "USBHost") require.NoError(t, err) - stdout, _, err := cli.Run("lib", "list", "--all", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--all", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `2`) // Verify both libraries have the same name @@ -1545,7 +1545,7 @@ func TestLibQueryParameters(t *testing.T) { require.Contains(t, string(stdout), `"url":"https://downloads.arduino.cc/libraries/github.com/arduino-libraries/USBHost-1.0.5.zip?query=upgrade"`) // Check query=depends when a library dependency is installed - stdout, _, err = cli.Run("lib", "deps", "MD_Parola@3.5.5", "--format", "json") + stdout, _, err = cli.Run("lib", "deps", "MD_Parola@3.5.5", "--json") require.NoError(t, err) // determine the version installed as dependency MDMAX72XXversion := strings.Trim(requirejson.Parse(t, stdout).Query(`.dependencies[0].version_required`).String(), `"`) @@ -1580,7 +1580,7 @@ func TestLibBundlesWhenLibWithTheSameNameIsInstalledGlobally(t *testing.T) { _, _, err := cli.Run("core", "install", "arduino:samd@1.8.13") require.NoError(t, err) { - stdout, _, err := cli.Run("lib", "list", "--all", "--fqbn", "arduino:samd:mkrzero", "USBHost", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--all", "--fqbn", "arduino:samd:mkrzero", "USBHost", "--json") require.NoError(t, err) j := requirejson.Parse(t, stdout) j.Query(`.installed_libraries.[0].library.name`).MustEqual(`"USBHost"`) @@ -1590,7 +1590,7 @@ func TestLibBundlesWhenLibWithTheSameNameIsInstalledGlobally(t *testing.T) { require.NoError(t, err) { // Check that the architecture-specific library is still listed - stdout, _, err := cli.Run("lib", "list", "--all", "--fqbn", "arduino:samd:mkrzero", "USBHost", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--all", "--fqbn", "arduino:samd:mkrzero", "USBHost", "--json") require.NoError(t, err) j := requirejson.Parse(t, stdout) j.Query(`.installed_libraries.[0].library.name`).MustEqual(`"USBHost"`) @@ -1605,7 +1605,7 @@ func TestLibBundlesWhenLibWithTheSameNameIsInstalledGlobally(t *testing.T) { require.NoError(t, err) _, _, err = cli.Run("lib", "install", "ArduinoOTA@1.0.7") require.NoError(t, err) - stdout, _, err := cli.Run("lib", "examples", "--fqbn", "esp8266:esp8266:generic", "ArduinoOTA", "--format", "json") + stdout, _, err := cli.Run("lib", "examples", "--fqbn", "esp8266:esp8266:generic", "ArduinoOTA", "--json") require.NoError(t, err) requirejson.Parse(t, stdout).Query(`.examples.[].library.examples[0]`).MustContain(`"BasicOTA"`) requirejson.Parse(t, stdout).Query(`.examples.[].library.examples[1]`).MustContain(`"OTALeds"`) @@ -1624,11 +1624,11 @@ func TestLibListDoesNotIncludeEmptyLibraries(t *testing.T) { require.NoError(t, emptyLib.MkdirAll()) // Check that the output of lib list and lib examples is empty - stdout, _, err := cli.Run("lib", "list", "--format", "json") + stdout, _, err := cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `0`) - stdout, _, err = cli.Run("lib", "examples", "--format", "json") + stdout, _, err = cli.Run("lib", "examples", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.examples | length`, `0`) @@ -1640,11 +1640,11 @@ func TestLibListDoesNotIncludeEmptyLibraries(t *testing.T) { require.NoError(t, f.Close()) // Check that the output of lib list and lib examples contains the library - stdout, _, err = cli.Run("lib", "list", "--format", "json") + stdout, _, err = cli.Run("lib", "list", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.installed_libraries | length`, `1`) - stdout, _, err = cli.Run("lib", "examples", "--format", "json") + stdout, _, err = cli.Run("lib", "examples", "--json") require.NoError(t, err) requirejson.Query(t, stdout, `.examples | length`, `1`) } @@ -1677,7 +1677,7 @@ func TestDependencyResolverNoOverwrite(t *testing.T) { _, _, err := cli.Run("lib", "install", "Bounce2@2.53.0") require.NoError(t, err) - out, _, err := cli.Run("lib", "deps", "EncoderTool@2.2.0", "--format", "json") + out, _, err := cli.Run("lib", "deps", "EncoderTool@2.2.0", "--json") require.NoError(t, err) outjson := requirejson.Parse(t, out) outjson.MustContain(`{ @@ -1695,7 +1695,7 @@ func TestDependencyResolverNoOverwrite(t *testing.T) { require.NotEqual(t, outjson.Query("dependencies[0].version_required").String(), `"2.53.0"`) require.NotEqual(t, outjson.Query("dependencies[0].version_required").String(), `"2.53"`) - out, _, err = cli.Run("lib", "deps", "EncoderTool@2.2.0", "--no-overwrite", "--format", "json") + out, _, err = cli.Run("lib", "deps", "EncoderTool@2.2.0", "--no-overwrite", "--json") require.NoError(t, err) outjson = requirejson.Parse(t, out) outjson.MustContain(`{ diff --git a/internal/integrationtest/main/main_test.go b/internal/integrationtest/main/main_test.go index 7e039e62768..b702e07aecc 100644 --- a/internal/integrationtest/main/main_test.go +++ b/internal/integrationtest/main/main_test.go @@ -48,8 +48,8 @@ func TestVersion(t *testing.T) { require.Contains(t, string(stdout), "Commit:") require.Empty(t, string(stderr)) - // Checks if "version --format json" has a json as an output - stdout, _, err = cli.Run("version", "--format", "json") + // Checks if "version --json" has a json as an output + stdout, _, err = cli.Run("version", "--json") require.NoError(t, err) var jsonMap map[string]string err = json.Unmarshal(stdout, &jsonMap) diff --git a/internal/integrationtest/profiles/profiles_test.go b/internal/integrationtest/profiles/profiles_test.go index ca26b75b4b3..aafd914db2c 100644 --- a/internal/integrationtest/profiles/profiles_test.go +++ b/internal/integrationtest/profiles/profiles_test.go @@ -89,12 +89,12 @@ func TestCompileWithDefaultProfile(t *testing.T) { { // no default profile -> error missing FQBN - _, _, err := cli.Run("compile", sketchWithoutDefProfilePath.String(), "--format", "json") + _, _, err := cli.Run("compile", sketchWithoutDefProfilePath.String(), "--json") require.Error(t, err) } { // specified fbqn -> compile with specified FQBN and use global installation - stdout, _, err := cli.Run("compile", "-b", "arduino:avr:nano", sketchWithoutDefProfilePath.String(), "--format", "json") + stdout, _, err := cli.Run("compile", "-b", "arduino:avr:nano", sketchWithoutDefProfilePath.String(), "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, stdout) jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.3"}`) @@ -102,7 +102,7 @@ func TestCompileWithDefaultProfile(t *testing.T) { } { // specified profile -> use the specified profile - stdout, _, err := cli.Run("compile", "--profile", "avr1", sketchWithoutDefProfilePath.String(), "--format", "json") + stdout, _, err := cli.Run("compile", "--profile", "avr1", sketchWithoutDefProfilePath.String(), "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, stdout) jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.4"}`) @@ -110,7 +110,7 @@ func TestCompileWithDefaultProfile(t *testing.T) { } { // specified profile and fqbn -> use the specified profile and override fqbn - stdout, _, err := cli.Run("compile", "--profile", "avr1", "-b", "arduino:avr:nano", sketchWithoutDefProfilePath.String(), "--format", "json") + stdout, _, err := cli.Run("compile", "--profile", "avr1", "-b", "arduino:avr:nano", sketchWithoutDefProfilePath.String(), "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, stdout) jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.4"}`) @@ -119,7 +119,7 @@ func TestCompileWithDefaultProfile(t *testing.T) { { // default profile -> use default profile - stdout, _, err := cli.Run("compile", sketchWithDefProfilePath.String(), "--format", "json") + stdout, _, err := cli.Run("compile", sketchWithDefProfilePath.String(), "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, stdout) jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.5"}`) @@ -127,7 +127,7 @@ func TestCompileWithDefaultProfile(t *testing.T) { } { // default profile, specified fbqn -> use default profile, override fqbn - stdout, _, err := cli.Run("compile", "-b", "arduino:avr:nano", sketchWithDefProfilePath.String(), "--format", "json") + stdout, _, err := cli.Run("compile", "-b", "arduino:avr:nano", sketchWithDefProfilePath.String(), "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, stdout) jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.5"}`) @@ -135,7 +135,7 @@ func TestCompileWithDefaultProfile(t *testing.T) { } { // default profile, specified different profile -> use the specified profile - stdout, _, err := cli.Run("compile", "--profile", "avr1", sketchWithDefProfilePath.String(), "--format", "json") + stdout, _, err := cli.Run("compile", "--profile", "avr1", sketchWithDefProfilePath.String(), "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, stdout) jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.4"}`) @@ -143,7 +143,7 @@ func TestCompileWithDefaultProfile(t *testing.T) { } { // default profile, specified different profile and fqbn -> use the specified profile and override fqbn - stdout, _, err := cli.Run("compile", "--profile", "avr1", "-b", "arduino:avr:nano", sketchWithDefProfilePath.String(), "--format", "json") + stdout, _, err := cli.Run("compile", "--profile", "avr1", "-b", "arduino:avr:nano", sketchWithDefProfilePath.String(), "--json") require.NoError(t, err) jsonOut := requirejson.Parse(t, stdout) jsonOut.Query(".builder_result.build_platform").MustContain(`{"id":"arduino:avr", "version":"1.8.4"}`) diff --git a/internal/integrationtest/upload/upload_test.go b/internal/integrationtest/upload/upload_test.go index b3c88cefeb9..0eebbe60ceb 100644 --- a/internal/integrationtest/upload/upload_test.go +++ b/internal/integrationtest/upload/upload_test.go @@ -40,13 +40,13 @@ type board struct { func detectedBoards(t *testing.T, cli *integrationtest.ArduinoCLI) []board { // This fixture provides a list of all the boards attached to the host. - // This fixture will parse the JSON output of `arduino-cli board list --format json` + // This fixture will parse the JSON output of `arduino-cli board list --json` // to extract all the connected boards data. // :returns a list `Board` objects. var boards []board - stdout, _, err := cli.Run("board", "list", "--format", "json") + stdout, _, err := cli.Run("board", "list", "--json") require.NoError(t, err) length, err := strconv.Atoi(requirejson.Parse(t, stdout).Query(".[] | .matching_boards | length").String()) require.NoError(t, err) @@ -67,7 +67,7 @@ func detectedBoards(t *testing.T, cli *integrationtest.ArduinoCLI) []board { func waitForBoard(t *testing.T, cli *integrationtest.ArduinoCLI) { timeEnd := time.Now().Unix() + 10 for time.Now().Unix() < timeEnd { - stdout, _, err := cli.Run("board", "list", "--format", "json") + stdout, _, err := cli.Run("board", "list", "--json") require.NoError(t, err) length, err := strconv.Atoi(requirejson.Parse(t, stdout).Query("length").String()) require.NoError(t, err) @@ -370,7 +370,7 @@ func TestUploadSketchWithPdeExtension(t *testing.T) { require.NoError(t, err) // Compile sketch first - stdout, _, err := cli.Run("compile", "--clean", "-b", board.fqbn, sketchPath.String(), "--format", "json") + stdout, _, err := cli.Run("compile", "--clean", "-b", board.fqbn, sketchPath.String(), "--json") require.NoError(t, err) buildDir := requirejson.Parse(t, stdout).Query(".builder_result | .build_path").String() buildDir = strings.Trim(strings.ReplaceAll(buildDir, "\\\\", "\\"), "\"") @@ -435,7 +435,7 @@ func TestUploadWithInputDirContainingMultipleBinaries(t *testing.T) { binariesDir := cli.SketchbookDir().Join("build", "BuiltBinaries") _, _, err = cli.Run("compile", "--clean", "-b", board.fqbn, sketchOnePath.String(), "--build-path", binariesDir.String()) require.NoError(t, err) - stdout, _, err := cli.Run("compile", "--clean", "-b", board.fqbn, sketchTwoPath.String(), "--format", "json") + stdout, _, err := cli.Run("compile", "--clean", "-b", board.fqbn, sketchTwoPath.String(), "--json") require.NoError(t, err) buildDirTwo := requirejson.Parse(t, stdout).Query(".builder_result | .build_path").String() buildDirTwo = strings.Trim(strings.ReplaceAll(buildDirTwo, "\\\\", "\\"), "\"")