diff --git a/CHANGELOG.md b/CHANGELOG.md index 67e48af..2162ad4 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## CHANGELOG -### v0.1.5 +### v0.1.5 (2020-01-09) * New array_length command * ForIn accepts handle value not variable name diff --git a/docs/api/duckscript/COPYRIGHT.txt b/docs/api/duckscript/COPYRIGHT.txt new file mode 100644 index 0000000..af77776 --- /dev/null +++ b/docs/api/duckscript/COPYRIGHT.txt @@ -0,0 +1,45 @@ +These documentation pages include resources by third parties. This copyright +file applies only to those resources. The following third party resources are +included, and carry their own copyright notices and license terms: + +* Fira Sans (FiraSans-Regular.woff, FiraSans-Medium.woff): + + Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ + with Reserved Font Name Fira Sans. + + Copyright (c) 2014, Telefonica S.A. + + Licensed under the SIL Open Font License, Version 1.1. + See FiraSans-LICENSE.txt. + +* rustdoc.css, main.js, and playpen.js: + + Copyright 2015 The Rust Developers. + Licensed under the Apache License, Version 2.0 (see LICENSE-APACHE.txt) or + the MIT license (LICENSE-MIT.txt) at your option. + +* normalize.css: + + Copyright (c) Nicolas Gallagher and Jonathan Neal. + Licensed under the MIT license (see LICENSE-MIT.txt). + +* Source Code Pro (SourceCodePro-Regular.woff, SourceCodePro-Semibold.woff): + + Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), + with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark + of Adobe Systems Incorporated in the United States and/or other countries. + + Licensed under the SIL Open Font License, Version 1.1. + See SourceCodePro-LICENSE.txt. + +* Source Serif Pro (SourceSerifPro-Regular.ttf.woff, + SourceSerifPro-Bold.ttf.woff, SourceSerifPro-It.ttf.woff): + + Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/), with + Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of + Adobe Systems Incorporated in the United States and/or other countries. + + Licensed under the SIL Open Font License, Version 1.1. + See SourceSerifPro-LICENSE.txt. + +This copyright file is intended to be distributed with rustdoc output. diff --git a/docs/api/duckscript/FiraSans-LICENSE.txt b/docs/api/duckscript/FiraSans-LICENSE.txt new file mode 100644 index 0000000..d444ea9 --- /dev/null +++ b/docs/api/duckscript/FiraSans-LICENSE.txt @@ -0,0 +1,94 @@ +Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. +with Reserved Font Name < Fira >, + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/api/duckscript/FiraSans-Medium.woff b/docs/api/duckscript/FiraSans-Medium.woff new file mode 100644 index 0000000..7d742c5 Binary files /dev/null and b/docs/api/duckscript/FiraSans-Medium.woff differ diff --git a/docs/api/duckscript/FiraSans-Regular.woff b/docs/api/duckscript/FiraSans-Regular.woff new file mode 100644 index 0000000..d8e0363 Binary files /dev/null and b/docs/api/duckscript/FiraSans-Regular.woff differ diff --git a/docs/api/duckscript/LICENSE-APACHE.txt b/docs/api/duckscript/LICENSE-APACHE.txt new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/docs/api/duckscript/LICENSE-APACHE.txt @@ -0,0 +1,201 @@ + 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. diff --git a/docs/api/duckscript/LICENSE-MIT.txt b/docs/api/duckscript/LICENSE-MIT.txt new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/docs/api/duckscript/LICENSE-MIT.txt @@ -0,0 +1,23 @@ +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. diff --git a/docs/api/duckscript/SourceCodePro-LICENSE.txt b/docs/api/duckscript/SourceCodePro-LICENSE.txt new file mode 100644 index 0000000..0754257 --- /dev/null +++ b/docs/api/duckscript/SourceCodePro-LICENSE.txt @@ -0,0 +1,93 @@ +Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/api/duckscript/SourceCodePro-Regular.woff b/docs/api/duckscript/SourceCodePro-Regular.woff new file mode 100644 index 0000000..5576670 Binary files /dev/null and b/docs/api/duckscript/SourceCodePro-Regular.woff differ diff --git a/docs/api/duckscript/SourceCodePro-Semibold.woff b/docs/api/duckscript/SourceCodePro-Semibold.woff new file mode 100644 index 0000000..ca972a1 Binary files /dev/null and b/docs/api/duckscript/SourceCodePro-Semibold.woff differ diff --git a/docs/api/duckscript/SourceSerifPro-Bold.ttf.woff b/docs/api/duckscript/SourceSerifPro-Bold.ttf.woff new file mode 100644 index 0000000..ca25431 Binary files /dev/null and b/docs/api/duckscript/SourceSerifPro-Bold.ttf.woff differ diff --git a/docs/api/duckscript/SourceSerifPro-It.ttf.woff b/docs/api/duckscript/SourceSerifPro-It.ttf.woff new file mode 100644 index 0000000..a287bbe Binary files /dev/null and b/docs/api/duckscript/SourceSerifPro-It.ttf.woff differ diff --git a/docs/api/duckscript/SourceSerifPro-LICENSE.md b/docs/api/duckscript/SourceSerifPro-LICENSE.md new file mode 100644 index 0000000..22cb755 --- /dev/null +++ b/docs/api/duckscript/SourceSerifPro-LICENSE.md @@ -0,0 +1,93 @@ +Copyright 2014-2018 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/api/duckscript/SourceSerifPro-Regular.ttf.woff b/docs/api/duckscript/SourceSerifPro-Regular.ttf.woff new file mode 100644 index 0000000..a3d55cf Binary files /dev/null and b/docs/api/duckscript/SourceSerifPro-Regular.ttf.woff differ diff --git a/docs/api/duckscript/aliases.js b/docs/api/duckscript/aliases.js new file mode 100644 index 0000000..cc5d7a5 --- /dev/null +++ b/docs/api/duckscript/aliases.js @@ -0,0 +1,2 @@ +var ALIASES = {}; +ALIASES["duckscript"] = {}; diff --git a/docs/api/duckscript/brush.svg b/docs/api/duckscript/brush.svg new file mode 100644 index 0000000..072264a --- /dev/null +++ b/docs/api/duckscript/brush.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/api/duckscript/dark.css b/docs/api/duckscript/dark.css new file mode 100644 index 0000000..0f090c4 --- /dev/null +++ b/docs/api/duckscript/dark.css @@ -0,0 +1 @@ +body{background-color:#353535;color:#ddd;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){color:#ddd;}h1.fqn{border-bottom-color:#d2d2d2;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){border-bottom-color:#d2d2d2;}.in-band{background-color:#353535;}.invisible{background:rgba(0,0,0,0);}.docblock code,.docblock-short code{background-color:#2A2A2A;}pre{background-color:#2A2A2A;}.sidebar{background-color:#505050;}.sidebar .current{background-color:#333;}.source .sidebar{background-color:#353535;}.sidebar .location{border-color:#fff;background:#575757;color:#DDD;}.sidebar .version{border-bottom-color:#DDD;}.sidebar-title{border-top-color:#777;border-bottom-color:#777;}.block a:hover{background:#444;}.line-numbers span{color:#3B91E2;}.line-numbers .line-highlighted{background-color:#0a042f !important;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom-color:#DDD;}.docblock table,.docblock table td,.docblock table th{border-color:#ddd;}.content .method .where,.content .fn .where,.content .where.fmt-newline{color:#ddd;}.content .highlighted{color:#eee !important;background-color:#616161;}.content .highlighted a,.content .highlighted span{color:#eee !important;}.content .highlighted.trait{background-color:#013191;}.content .highlighted.traitalias{background-color:#013191;}.content .highlighted.mod,.content .highlighted.externcrate{background-color:#afc6e4;}.content .highlighted.mod{background-color:#803a1b;}.content .highlighted.externcrate{background-color:#396bac;}.content .highlighted.enum{background-color:#5b4e68;}.content .highlighted.struct{background-color:#194e9f;}.content .highlighted.union{background-color:#b7bd49;}.content .highlighted.fn,.content .highlighted.method,.content .highlighted.tymethod{background-color:#4950ed;}.content .highlighted.type{background-color:#38902c;}.content .highlighted.foreigntype{background-color:#b200d6;}.content .highlighted.attr,.content .highlighted.derive,.content .highlighted.macro{background-color:#217d1c;}.content .highlighted.constant,.content .highlighted.static{background-color:#0063cc;}.content .highlighted.primitive{background-color:#00708a;}.content .highlighted.keyword{background-color:#884719;}.content span.enum,.content a.enum,.block a.current.enum{color:#82b089;}.content span.struct,.content a.struct,.block a.current.struct{color:#2dbfb8;}.content span.type,.content a.type,.block a.current.type{color:#ff7f00;}.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype{color:#dd7de8;}.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro{color:#09bd00;}.content span.union,.content a.union,.block a.current.union{color:#a6ae37;}.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static{color:#82a5c9;}.content span.primitive,.content a.primitive,.block a.current.primitive{color:#43aec7;}.content span.externcrate,.content span.mod,.content a.mod,.block a.current.mod{color:#bda000;}.content span.trait,.content a.trait,.block a.current.trait{color:#b78cf2;}.content span.traitalias,.content a.traitalias,.block a.current.traitalias{color:#b397da;}.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname{color:#2BAB63;}.content span.keyword,.content a.keyword,.block a.current.keyword{color:#de5249;}pre.rust .comment{color:#8d8d8b;}pre.rust .doccomment{color:#8ca375;}nav{border-bottom-color:#4e4e4e;}nav.main .current{border-top-color:#eee;border-bottom-color:#eee;}nav.main .separator{border-color:#eee;}a{color:#ddd;}.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow),.docblock-short a:not(.srclink):not(.test-arrow),.stability a{color:#D2991D;}.stab.internal a{color:#304FFE;}a.test-arrow{color:#dedede;}.collapse-toggle{color:#999;}#crate-search{color:#111;background-color:#f0f0f0;border-color:#000;box-shadow:0 0 0 1px #000,0 0 0 2px transparent;}.search-input{color:#111;background-color:#f0f0f0;box-shadow:0 0 0 1px #000,0 0 0 2px transparent;}.search-input:focus{border-color:#008dfd;}#crate-search+.search-input:focus{box-shadow:0 0 8px 4px #078dd8;}.module-item .stab{color:#ddd;}.stab.unstable{background:#FFF5D6;border-color:#FFC600;color:#2f2f2f;}.stab.internal{background:#FFB9B3;border-color:#B71C1C;color:#2f2f2f;}.stab.deprecated{background:#F3DFFF;border-color:#7F0087;color:#2f2f2f;}.stab.portability{background:#C4ECFF;border-color:#7BA5DB;color:#2f2f2f;}.stab.portability>code{color:#ddd;}#help>div{background:#4d4d4d;border-color:#bfbfbf;}#help dt{border-color:#bfbfbf;background:rgba(0,0,0,0);color:black;}.since{color:grey;}tr.result span.primitive::after,tr.result span.keyword::after{color:#ddd;}.line-numbers :target{background-color:transparent;}pre.rust .kw{color:#ab8ac1;}pre.rust .kw-2,pre.rust .prelude-ty{color:#769acb;}pre.rust .number,pre.rust .string{color:#83a300;}pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident{color:#ee6868;}pre.rust .macro,pre.rust .macro-nonterminal{color:#3E999F;}pre.rust .lifetime{color:#d97f26;}pre.rust .question-mark{color:#ff9011;}.example-wrap>pre.line-number{border-color:#4a4949;}a.test-arrow{background-color:rgba(78,139,202,0.2);}a.test-arrow:hover{background-color:#4e8bca;}.toggle-label{color:#999;}:target>code,:target>.in-band{background-color:#494a3d;}pre.compile_fail{border-left:2px solid rgba(255,0,0,.6);}pre.compile_fail:hover,.information:hover+pre.compile_fail{border-left:2px solid #f00;}pre.ignore{border-left:2px solid rgba(255,142,0,.6);}pre.ignore:hover,.information:hover+pre.ignore{border-left:2px solid #ff9200;}.tooltip.compile_fail{color:rgba(255,0,0,.6);}.information>.compile_fail:hover{color:#f00;}.tooltip.ignore{color:rgba(255,142,0,.6);}.information>.ignore:hover{color:rgba(255,142,0,1);}.search-failed a{color:#0089ff;}.tooltip .tooltiptext{background-color:black;color:#fff;}.tooltip .tooltiptext::after{border-color:transparent black transparent transparent;}.important-traits .tooltip .tooltiptext{background-color:white;color:black;border-color:black;}#titles>div:not(.selected){background-color:#252525;border-top-color:#252525;}#titles>div:hover,#titles>div.selected{border-top-color:#0089ff;}#titles>div>div.count{color:#888;}.modal{background-color:rgba(0,0,0,0.3);}.modal-content{background-color:#272727;border-color:#999;}.modal-content>.close{background-color:#272727;border-color:#999;}.modal-content>.close:hover{background-color:#ff1f1f;color:white;}.modal-content>.whiter{background-color:#272727;}.modal-content>.close:hover+.whiter{background-color:#ff1f1f;}@media (max-width:700px){.sidebar-menu{background-color:#505050;border-bottom-color:#e0e0e0;border-right-color:#e0e0e0;}.sidebar-elems{background-color:#505050;border-right-color:#000;}#sidebar-filler{background-color:#505050;border-bottom-color:#e0e0e0;}}kbd{color:#000;background-color:#fafbfc;border-color:#d1d5da;border-bottom-color:#c6cbd1;box-shadow-color:#c6cbd1;}#theme-picker,#settings-menu{border-color:#e0e0e0;background:#f0f0f0;}#theme-picker:hover,#theme-picker:focus,#settings-menu:hover,#settings-menu:focus{border-color:#ffb900;}#theme-choices{border-color:#e0e0e0;background-color:#353535;}#theme-choices>button:not(:first-child){border-top-color:#e0e0e0;}#theme-choices>button:hover,#theme-choices>button:focus{background-color:#4e4e4e;}@media (max-width:700px){#theme-picker{background:#f0f0f0;}}#all-types{background-color:#505050;}#all-types:hover{background-color:#606060;}.search-results td span.alias{color:#fff;}.search-results td span.grey{color:#ccc;}#sidebar-toggle{background-color:#565656;}#sidebar-toggle:hover{background-color:#676767;}#source-sidebar{background-color:#565656;}#source-sidebar>.title{border-bottom-color:#ccc;}div.files>a:hover,div.name:hover{background-color:#444;}div.files>.selected{background-color:#333;} \ No newline at end of file diff --git a/docs/api/duckscript/down-arrow.svg b/docs/api/duckscript/down-arrow.svg new file mode 100644 index 0000000..c0f59f0 --- /dev/null +++ b/docs/api/duckscript/down-arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/api/duckscript/duckscript/all.html b/docs/api/duckscript/duckscript/all.html new file mode 100644 index 0000000..2e19187 --- /dev/null +++ b/docs/api/duckscript/duckscript/all.html @@ -0,0 +1,3 @@ +List of all items in this crate

[] + + List of all items

Structs

Enums

Traits

Functions

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/index.html b/docs/api/duckscript/duckscript/index.html new file mode 100644 index 0000000..56e12dc --- /dev/null +++ b/docs/api/duckscript/duckscript/index.html @@ -0,0 +1,19 @@ +duckscript - Rust

[][src]Crate duckscript

duckscript

+

Simple, extendable and embeddable scripting language.

+

This library is the actual script parser and runner.
+On it's own, it has no actual commands as those need to be provided externally (see duckscript_sdk).

+

Installation

+

In order to use this library, just add it as a dependency:

+
[dependencies]
+duckscript = "*"
+
+

Contributing

+

See contributing guide

+

License

+

Developed by Sagie Gur-Ari and licensed under the +Apache 2 open source license.

+

Modules

+
parser

parser

+
runner

runner

+
types

types

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/parser/fn.parse_file.html b/docs/api/duckscript/duckscript/parser/fn.parse_file.html new file mode 100644 index 0000000..7329daf --- /dev/null +++ b/docs/api/duckscript/duckscript/parser/fn.parse_file.html @@ -0,0 +1,2 @@ +duckscript::parser::parse_file - Rust

[][src]Function duckscript::parser::parse_file

pub fn parse_file(file: &str) -> Result<Vec<Instruction>, ScriptError>

parses the file and returns a vector of instructions

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/parser/fn.parse_text.html b/docs/api/duckscript/duckscript/parser/fn.parse_text.html new file mode 100644 index 0000000..4c73199 --- /dev/null +++ b/docs/api/duckscript/duckscript/parser/fn.parse_text.html @@ -0,0 +1,2 @@ +duckscript::parser::parse_text - Rust

[][src]Function duckscript::parser::parse_text

pub fn parse_text(text: &str) -> Result<Vec<Instruction>, ScriptError>

parses the provided script text and returns a vector of instructions

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/parser/index.html b/docs/api/duckscript/duckscript/parser/index.html new file mode 100644 index 0000000..db81439 --- /dev/null +++ b/docs/api/duckscript/duckscript/parser/index.html @@ -0,0 +1,6 @@ +duckscript::parser - Rust

[][src]Module duckscript::parser

parser

+

The duck script parser.

+

Functions

+
parse_file

parses the file and returns a vector of instructions

+
parse_text

parses the provided script text and returns a vector of instructions

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/parser/sidebar-items.js b/docs/api/duckscript/duckscript/parser/sidebar-items.js new file mode 100644 index 0000000..84f6ab1 --- /dev/null +++ b/docs/api/duckscript/duckscript/parser/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"fn":[["parse_file","parses the file and returns a vector of instructions"],["parse_text","parses the provided script text and returns a vector of instructions"]]}); \ No newline at end of file diff --git a/docs/api/duckscript/duckscript/runner/fn.run_instruction.html b/docs/api/duckscript/duckscript/runner/fn.run_instruction.html new file mode 100644 index 0000000..87e7d8a --- /dev/null +++ b/docs/api/duckscript/duckscript/runner/fn.run_instruction.html @@ -0,0 +1,2 @@ +duckscript::runner::run_instruction - Rust

[][src]Function duckscript::runner::run_instruction

pub fn run_instruction(
    commands: &mut Commands,
    variables: &mut HashMap<String, String>,
    state: &mut HashMap<String, StateValue>,
    instructions: &Vec<Instruction>,
    instruction: Instruction,
    line: usize
) -> (CommandResult, Option<String>)

Enables to evaluate a single instruction and return its result.

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/runner/fn.run_script.html b/docs/api/duckscript/duckscript/runner/fn.run_script.html new file mode 100644 index 0000000..1eb911a --- /dev/null +++ b/docs/api/duckscript/duckscript/runner/fn.run_script.html @@ -0,0 +1,2 @@ +duckscript::runner::run_script - Rust

[][src]Function duckscript::runner::run_script

pub fn run_script(text: &str, context: Context) -> Result<Context, ScriptError>

Executes the provided script with the given context

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/runner/fn.run_script_file.html b/docs/api/duckscript/duckscript/runner/fn.run_script_file.html new file mode 100644 index 0000000..8ef99d0 --- /dev/null +++ b/docs/api/duckscript/duckscript/runner/fn.run_script_file.html @@ -0,0 +1,2 @@ +duckscript::runner::run_script_file - Rust

[][src]Function duckscript::runner::run_script_file

pub fn run_script_file(
    file: &str,
    context: Context
) -> Result<Context, ScriptError>

Executes the provided script file with the given context

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/runner/index.html b/docs/api/duckscript/duckscript/runner/index.html new file mode 100644 index 0000000..3b75e32 --- /dev/null +++ b/docs/api/duckscript/duckscript/runner/index.html @@ -0,0 +1,7 @@ +duckscript::runner - Rust

[][src]Module duckscript::runner

runner

+

The main entry point which enables running scripts.

+

Functions

+
run_instruction

Enables to evaluate a single instruction and return its result.

+
run_script

Executes the provided script with the given context

+
run_script_file

Executes the provided script file with the given context

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/runner/sidebar-items.js b/docs/api/duckscript/duckscript/runner/sidebar-items.js new file mode 100644 index 0000000..6dae191 --- /dev/null +++ b/docs/api/duckscript/duckscript/runner/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"fn":[["run_instruction","Enables to evaluate a single instruction and return its result."],["run_script","Executes the provided script with the given context"],["run_script_file","Executes the provided script file with the given context"]]}); \ No newline at end of file diff --git a/docs/api/duckscript/duckscript/sidebar-items.js b/docs/api/duckscript/duckscript/sidebar-items.js new file mode 100644 index 0000000..66be98c --- /dev/null +++ b/docs/api/duckscript/duckscript/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"mod":[["parser","parser"],["runner","runner"],["types","types"]]}); \ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/command/enum.CommandResult.html b/docs/api/duckscript/duckscript/types/command/enum.CommandResult.html new file mode 100644 index 0000000..1899828 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/command/enum.CommandResult.html @@ -0,0 +1,31 @@ +duckscript::types::command::CommandResult - Rust

[][src]Enum duckscript::types::command::CommandResult

pub enum CommandResult {
+    Continue(Option<String>),
+    GoTo(Option<String>, GoToValue),
+    Error(String),
+    Crash(String),
+    Exit(Option<String>),
+}

Command execution result

+

+ Variants

+Continue(Option<String>)

Holds the command output and tells the runner to continue to next instruction

+
GoTo(Option<String>, GoToValue)

Holds the command output and tells the runner to jump to the provided label

+
Error(String)

Holds the error message and the meta info of the instruction that caused it

+
Crash(String)

Holds the critical error message and the meta info of the instruction that caused it

+
Exit(Option<String>)

Holds the command output and tells the runner to stop the script execution

+

Trait Implementations

impl Clone for CommandResult[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

+

impl Debug for CommandResult[src]

Auto Trait Implementations

impl Send for CommandResult

impl Unpin for CommandResult

impl Sync for CommandResult

impl RefUnwindSafe for CommandResult

impl UnwindSafe for CommandResult

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/command/enum.GoToValue.html b/docs/api/duckscript/duckscript/types/command/enum.GoToValue.html new file mode 100644 index 0000000..c11da2c --- /dev/null +++ b/docs/api/duckscript/duckscript/types/command/enum.GoToValue.html @@ -0,0 +1,25 @@ +duckscript::types::command::GoToValue - Rust

[][src]Enum duckscript::types::command::GoToValue

pub enum GoToValue {
+    Label(String),
+    Line(usize),
+}

GoTo type value

+

+ Variants

+Label(String)

label target

+
Line(usize)

Line number

+

Trait Implementations

impl Clone for GoToValue[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

+

impl Debug for GoToValue[src]

Auto Trait Implementations

impl Send for GoToValue

impl Unpin for GoToValue

impl Sync for GoToValue

impl RefUnwindSafe for GoToValue

impl UnwindSafe for GoToValue

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/command/index.html b/docs/api/duckscript/duckscript/types/command/index.html new file mode 100644 index 0000000..1fc1412 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/command/index.html @@ -0,0 +1,10 @@ +duckscript::types::command - Rust

[][src]Module duckscript::types::command

command

+

The command trait and access module.

+

Structs

+
Commands

Holds and enables access to the runtime commands implementations

+

Enums

+
CommandResult

Command execution result

+
GoToValue

GoTo type value

+

Traits

+
Command

Defines the command capabilities

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/command/sidebar-items.js b/docs/api/duckscript/duckscript/types/command/sidebar-items.js new file mode 100644 index 0000000..25d9766 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/command/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"enum":[["CommandResult","Command execution result"],["GoToValue","GoTo type value"]],"struct":[["Commands","Holds and enables access to the runtime commands implementations"]],"trait":[["Command","Defines the command capabilities"]]}); \ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/command/struct.Commands.html b/docs/api/duckscript/duckscript/types/command/struct.Commands.html new file mode 100644 index 0000000..d7aa64a --- /dev/null +++ b/docs/api/duckscript/duckscript/types/command/struct.Commands.html @@ -0,0 +1,28 @@ +duckscript::types::command::Commands - Rust

[][src]Struct duckscript::types::command::Commands

pub struct Commands {
+    pub commands: HashMap<String, Box<dyn Command>>,
+    pub aliases: HashMap<String, String>,
+}

Holds and enables access to the runtime commands implementations

+

+ Fields

commands: HashMap<String, Box<dyn Command>>

mapping between command names to implementations

+
aliases: HashMap<String, String>

mapping between aliases to command names

+

Methods

impl Commands[src]

pub fn new() -> Commands[src]

Creates and returns a new instance.

+

pub fn return_after_usage(&mut self, command: Box<dyn Command>)[src]

Returns the command after it was being used. +No validations will be made.

+

pub fn set(&mut self, command: Box<dyn Command>) -> Result<(), ScriptError>[src]

Adds a new command definition. +It will fail in case another command already defined the same name/aliases

+

pub fn get(&self, name: &str) -> Option<&Box<dyn Command>>[src]

Return the command based on the given command name/alias

+

pub fn exists(&self, name: &str) -> bool[src]

Return true if the command based on the given command name/alias exists

+

pub fn get_for_use(&mut self, name: &str) -> Option<Box<dyn Command>>[src]

Return the command based on the given command name/alias. +It will also remove it in the process.

+

pub fn get_all_command_names(&self) -> Vec<String>[src]

Returns all the command names currently registered

+

pub fn remove(&mut self, name: &str)[src]

Removes the requested command.

+

Auto Trait Implementations

impl !Send for Commands

impl Unpin for Commands

impl !Sync for Commands

impl !RefUnwindSafe for Commands

impl !UnwindSafe for Commands

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/command/trait.Command.html b/docs/api/duckscript/duckscript/types/command/trait.Command.html new file mode 100644 index 0000000..77b7f1e --- /dev/null +++ b/docs/api/duckscript/duckscript/types/command/trait.Command.html @@ -0,0 +1,31 @@ +duckscript::types::command::Command - Rust

[][src]Trait duckscript::types::command::Command

pub trait Command {
+    fn name(&self) -> String;
+
+    fn aliases(&self) -> Vec<String> { ... }
+
fn help(&self) -> String { ... } +
fn requires_context(&self) -> bool { ... } +
fn run(&self, _arguments: Vec<String>) -> CommandResult { ... } +
fn run_with_context(
        &self,
        _arguments: Vec<String>,
        _state: &mut HashMap<String, StateValue>,
        _variables: &mut HashMap<String, String>,
        _output_variable: Option<String>,
        _instructions: &Vec<Instruction>,
        _commands: &mut Commands,
        _line: usize
    ) -> CommandResult { ... } +}

Defines the command capabilities

+
+

Required methods

fn name(&self) -> String

The full command name which can be used to invoke this command.

+
Loading content... +

Provided methods

fn aliases(&self) -> Vec<String>

A list of aliases that can also be used to invoke this command.

+

fn help(&self) -> String

Command documentation.

+

fn requires_context(&self) -> bool

If true the run with the context will be invoked.

+

fn run(&self, _arguments: Vec<String>) -> CommandResult

Runs the given instruction

+

fn run_with_context(
    &self,
    _arguments: Vec<String>,
    _state: &mut HashMap<String, StateValue>,
    _variables: &mut HashMap<String, String>,
    _output_variable: Option<String>,
    _instructions: &Vec<Instruction>,
    _commands: &mut Commands,
    _line: usize
) -> CommandResult

Run the instruction with access to the runtime context.

+

Arguments

+
    +
  • arguments - The command arguments array
  • +
  • state - Internal state which is only used by commands to store/pull data
  • +
  • variables - All script variables
  • +
  • output_variable - The output variable name (if defined)
  • +
  • instructions - The entire list of instructions which make up the currently running script
  • +
  • commands - The currently known commands
  • +
  • line - The current instruction line number (global line number after including all scripts into one global script)
  • +
+
Loading content... +

Implementors

Loading content...
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/error/enum.ErrorInfo.html b/docs/api/duckscript/duckscript/types/error/enum.ErrorInfo.html new file mode 100644 index 0000000..4b20404 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/error/enum.ErrorInfo.html @@ -0,0 +1,39 @@ +duckscript::types::error::ErrorInfo - Rust

[][src]Enum duckscript::types::error::ErrorInfo

pub enum ErrorInfo {
+    ErrorReadingFile(StringOption<Error>),
+    Initialization(String),
+    Runtime(StringOption<InstructionMetaInfo>),
+    PreProcessNoCommandFound(InstructionMetaInfo),
+    ControlWithoutValidValue(InstructionMetaInfo),
+    InvalidControlLocation(InstructionMetaInfo),
+    MissingEndQuotes(InstructionMetaInfo),
+    MissingOutputVariableName(InstructionMetaInfo),
+    InvalidEqualsLocation(InstructionMetaInfo),
+    InvalidQuotesLocation(InstructionMetaInfo),
+    EmptyLabel(InstructionMetaInfo),
+    UnknownPreProcessorCommand(InstructionMetaInfo),
+}

Holds the error information

+

+ Variants

+ErrorReadingFile(StringOption<Error>)

Error Info Type

+
Initialization(String)

Error Info Type

+
Runtime(StringOption<InstructionMetaInfo>)

Error Info Type

+
PreProcessNoCommandFound(InstructionMetaInfo)

Error Info Type

+
ControlWithoutValidValue(InstructionMetaInfo)

Error Info Type

+
InvalidControlLocation(InstructionMetaInfo)

Error Info Type

+
MissingEndQuotes(InstructionMetaInfo)

Error Info Type

+
MissingOutputVariableName(InstructionMetaInfo)

Error Info Type

+
InvalidEqualsLocation(InstructionMetaInfo)

Error Info Type

+
InvalidQuotesLocation(InstructionMetaInfo)

Error Info Type

+
EmptyLabel(InstructionMetaInfo)

Error Info Type

+
UnknownPreProcessorCommand(InstructionMetaInfo)

Error Info Type

+

Trait Implementations

impl Debug for ErrorInfo[src]

Auto Trait Implementations

impl Send for ErrorInfo

impl Unpin for ErrorInfo

impl Sync for ErrorInfo

impl !RefUnwindSafe for ErrorInfo

impl !UnwindSafe for ErrorInfo

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/error/index.html b/docs/api/duckscript/duckscript/types/error/index.html new file mode 100644 index 0000000..5e2bed5 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/error/index.html @@ -0,0 +1,7 @@ +duckscript::types::error - Rust

[][src]Module duckscript::types::error

error

+

The error structure and types.

+

Structs

+
ScriptError

Script error struct

+

Enums

+
ErrorInfo

Holds the error information

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/error/sidebar-items.js b/docs/api/duckscript/duckscript/types/error/sidebar-items.js new file mode 100644 index 0000000..72c1f18 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/error/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"enum":[["ErrorInfo","Holds the error information"]],"struct":[["ScriptError","Script error struct"]]}); \ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/error/struct.ScriptError.html b/docs/api/duckscript/duckscript/types/error/struct.ScriptError.html new file mode 100644 index 0000000..2876e66 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/error/struct.ScriptError.html @@ -0,0 +1,18 @@ +duckscript::types::error::ScriptError - Rust

[][src]Struct duckscript::types::error::ScriptError

pub struct ScriptError {
+    pub info: ErrorInfo,
+}

Script error struct

+

+ Fields

info: ErrorInfo

Holds the error information

+

Trait Implementations

impl Display for ScriptError[src]

fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error>[src]

Formats the script error using the given formatter.

+

impl Debug for ScriptError[src]

Auto Trait Implementations

impl Send for ScriptError

impl Unpin for ScriptError

impl Sync for ScriptError

impl !RefUnwindSafe for ScriptError

impl !UnwindSafe for ScriptError

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/index.html b/docs/api/duckscript/duckscript/types/index.html new file mode 100644 index 0000000..24ad9e6 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/index.html @@ -0,0 +1,8 @@ +duckscript::types - Rust

[][src]Module duckscript::types

types

+

All duckscript types.

+

Modules

+
command

command

+
error

error

+
instruction

instruction

+
runtime

runtime

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/instruction/enum.InstructionType.html b/docs/api/duckscript/duckscript/types/instruction/enum.InstructionType.html new file mode 100644 index 0000000..571ef71 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/instruction/enum.InstructionType.html @@ -0,0 +1,27 @@ +duckscript::types::instruction::InstructionType - Rust

[][src]Enum duckscript::types::instruction::InstructionType

pub enum InstructionType {
+    Empty,
+    PreProcess(PreProcessInstruction),
+    Script(ScriptInstruction),
+}

Instruction Type - script, preprocess

+

+ Variants

+Empty

Empty instruction

+
PreProcess(PreProcessInstruction)

Preprocess instruction

+
Script(ScriptInstruction)

Runtime script instruction

+

Trait Implementations

impl Clone for InstructionType[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

+

impl Debug for InstructionType[src]

Auto Trait Implementations

impl Send for InstructionType

impl Unpin for InstructionType

impl Sync for InstructionType

impl RefUnwindSafe for InstructionType

impl UnwindSafe for InstructionType

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/instruction/index.html b/docs/api/duckscript/duckscript/types/instruction/index.html new file mode 100644 index 0000000..0d5189b --- /dev/null +++ b/docs/api/duckscript/duckscript/types/instruction/index.html @@ -0,0 +1,10 @@ +duckscript::types::instruction - Rust

[][src]Module duckscript::types::instruction

instruction

+

The instruction type.

+

Structs

+
Instruction

Instruction data

+
InstructionMetaInfo

Meta information for all instruction types

+
PreProcessInstruction

Preprocess instruction

+
ScriptInstruction

Runtime script instruction

+

Enums

+
InstructionType

Instruction Type - script, preprocess

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/instruction/sidebar-items.js b/docs/api/duckscript/duckscript/types/instruction/sidebar-items.js new file mode 100644 index 0000000..99fac17 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/instruction/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"enum":[["InstructionType","Instruction Type - script, preprocess"]],"struct":[["Instruction","Instruction data"],["InstructionMetaInfo","Meta information for all instruction types"],["PreProcessInstruction","Preprocess instruction"],["ScriptInstruction","Runtime script instruction"]]}); \ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/instruction/struct.Instruction.html b/docs/api/duckscript/duckscript/types/instruction/struct.Instruction.html new file mode 100644 index 0000000..72a0cf2 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/instruction/struct.Instruction.html @@ -0,0 +1,24 @@ +duckscript::types::instruction::Instruction - Rust

[][src]Struct duckscript::types::instruction::Instruction

pub struct Instruction {
+    pub meta_info: InstructionMetaInfo,
+    pub instruction_type: InstructionType,
+}

Instruction data

+

+ Fields

meta_info: InstructionMetaInfo

Meta info

+
instruction_type: InstructionType

The instruction

+

Trait Implementations

impl Clone for Instruction[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

+

impl Debug for Instruction[src]

Auto Trait Implementations

impl Send for Instruction

impl Unpin for Instruction

impl Sync for Instruction

impl RefUnwindSafe for Instruction

impl UnwindSafe for Instruction

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/instruction/struct.InstructionMetaInfo.html b/docs/api/duckscript/duckscript/types/instruction/struct.InstructionMetaInfo.html new file mode 100644 index 0000000..4d901aa --- /dev/null +++ b/docs/api/duckscript/duckscript/types/instruction/struct.InstructionMetaInfo.html @@ -0,0 +1,25 @@ +duckscript::types::instruction::InstructionMetaInfo - Rust

[][src]Struct duckscript::types::instruction::InstructionMetaInfo

pub struct InstructionMetaInfo {
+    pub line: Option<usize>,
+    pub source: Option<String>,
+}

Meta information for all instruction types

+

+ Fields

line: Option<usize>

The line number

+
source: Option<String>

The source file/url/...

+

Methods

impl InstructionMetaInfo[src]

pub fn new() -> InstructionMetaInfo[src]

Creates and returns a new instance.

+

Trait Implementations

impl Clone for InstructionMetaInfo[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

+

impl Debug for InstructionMetaInfo[src]

Auto Trait Implementations

impl Send for InstructionMetaInfo

impl Unpin for InstructionMetaInfo

impl Sync for InstructionMetaInfo

impl RefUnwindSafe for InstructionMetaInfo

impl UnwindSafe for InstructionMetaInfo

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/instruction/struct.PreProcessInstruction.html b/docs/api/duckscript/duckscript/types/instruction/struct.PreProcessInstruction.html new file mode 100644 index 0000000..81ae691 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/instruction/struct.PreProcessInstruction.html @@ -0,0 +1,25 @@ +duckscript::types::instruction::PreProcessInstruction - Rust

[][src]Struct duckscript::types::instruction::PreProcessInstruction

pub struct PreProcessInstruction {
+    pub command: Option<String>,
+    pub arguments: Option<Vec<String>>,
+}

Preprocess instruction

+

+ Fields

command: Option<String>

The command name

+
arguments: Option<Vec<String>>

The command arguments

+

Methods

impl PreProcessInstruction[src]

pub fn new() -> PreProcessInstruction[src]

Creates and returns a new instance.

+

Trait Implementations

impl Clone for PreProcessInstruction[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

+

impl Debug for PreProcessInstruction[src]

Auto Trait Implementations

impl Send for PreProcessInstruction

impl Unpin for PreProcessInstruction

impl Sync for PreProcessInstruction

impl RefUnwindSafe for PreProcessInstruction

impl UnwindSafe for PreProcessInstruction

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/instruction/struct.ScriptInstruction.html b/docs/api/duckscript/duckscript/types/instruction/struct.ScriptInstruction.html new file mode 100644 index 0000000..ccda11f --- /dev/null +++ b/docs/api/duckscript/duckscript/types/instruction/struct.ScriptInstruction.html @@ -0,0 +1,29 @@ +duckscript::types::instruction::ScriptInstruction - Rust

[][src]Struct duckscript::types::instruction::ScriptInstruction

pub struct ScriptInstruction {
+    pub label: Option<String>,
+    pub output: Option<String>,
+    pub command: Option<String>,
+    pub arguments: Option<Vec<String>>,
+}

Runtime script instruction

+

+ Fields

label: Option<String>

The label tag

+
output: Option<String>

The command output variable name

+
command: Option<String>

The command name

+
arguments: Option<Vec<String>>

The command arguments

+

Methods

impl ScriptInstruction[src]

pub fn new() -> ScriptInstruction[src]

Creates and returns a new instance.

+

Trait Implementations

impl Clone for ScriptInstruction[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

+

impl Debug for ScriptInstruction[src]

Auto Trait Implementations

impl Send for ScriptInstruction

impl Unpin for ScriptInstruction

impl Sync for ScriptInstruction

impl RefUnwindSafe for ScriptInstruction

impl UnwindSafe for ScriptInstruction

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/runtime/enum.StateValue.html b/docs/api/duckscript/duckscript/types/runtime/enum.StateValue.html new file mode 100644 index 0000000..df29514 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/runtime/enum.StateValue.html @@ -0,0 +1,41 @@ +duckscript::types::runtime::StateValue - Rust

[][src]Enum duckscript::types::runtime::StateValue

pub enum StateValue {
+    Boolean(bool),
+    Number(isize),
+    UnsignedNumber(usize),
+    Number32Bit(i32),
+    UnsignedNumber32Bit(u32),
+    Number64Bit(i64),
+    UnsignedNumber64Bit(u64),
+    String(String),
+    List(Vec<StateValue>),
+    SubState(HashMap<String, StateValue>),
+}

enum defining what values can be stored in the state map

+

+ Variants

+Boolean(bool)

boolean value

+
Number(isize)

signed number

+
UnsignedNumber(usize)

unsigned number

+
Number32Bit(i32)

signed number

+
UnsignedNumber32Bit(u32)

unsigned number

+
Number64Bit(i64)

signed number

+
UnsignedNumber64Bit(u64)

unsigned number

+
String(String)

textual value

+
List(Vec<StateValue>)

list

+
SubState(HashMap<String, StateValue>)

sub state value

+

Trait Implementations

impl Clone for StateValue[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

+

impl Debug for StateValue[src]

Auto Trait Implementations

impl Send for StateValue

impl Unpin for StateValue

impl Sync for StateValue

impl RefUnwindSafe for StateValue

impl UnwindSafe for StateValue

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/runtime/index.html b/docs/api/duckscript/duckscript/types/runtime/index.html new file mode 100644 index 0000000..6a5a17c --- /dev/null +++ b/docs/api/duckscript/duckscript/types/runtime/index.html @@ -0,0 +1,8 @@ +duckscript::types::runtime - Rust

[][src]Module duckscript::types::runtime

runtime

+

The runtime context structures.

+

Structs

+
Context

The context structure

+
Runtime

The runtime structure

+

Enums

+
StateValue

enum defining what values can be stored in the state map

+
\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/runtime/sidebar-items.js b/docs/api/duckscript/duckscript/types/runtime/sidebar-items.js new file mode 100644 index 0000000..35a9648 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/runtime/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"enum":[["StateValue","enum defining what values can be stored in the state map"]],"struct":[["Context","The context structure"],["Runtime","The runtime structure"]]}); \ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/runtime/struct.Context.html b/docs/api/duckscript/duckscript/types/runtime/struct.Context.html new file mode 100644 index 0000000..dd436a9 --- /dev/null +++ b/docs/api/duckscript/duckscript/types/runtime/struct.Context.html @@ -0,0 +1,20 @@ +duckscript::types::runtime::Context - Rust

[][src]Struct duckscript::types::runtime::Context

pub struct Context {
+    pub variables: HashMap<String, String>,
+    pub state: HashMap<String, StateValue>,
+    pub commands: Commands,
+}

The context structure

+

+ Fields

variables: HashMap<String, String>

The runtime variables

+
state: HashMap<String, StateValue>

The runtime state

+
commands: Commands

The command implementations

+

Methods

impl Context[src]

pub fn new() -> Context[src]

Creates and returns a new instance.

+

Auto Trait Implementations

impl !Send for Context

impl Unpin for Context

impl !Sync for Context

impl !RefUnwindSafe for Context

impl !UnwindSafe for Context

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/runtime/struct.Runtime.html b/docs/api/duckscript/duckscript/types/runtime/struct.Runtime.html new file mode 100644 index 0000000..12e6adb --- /dev/null +++ b/docs/api/duckscript/duckscript/types/runtime/struct.Runtime.html @@ -0,0 +1,20 @@ +duckscript::types::runtime::Runtime - Rust

[][src]Struct duckscript::types::runtime::Runtime

pub struct Runtime {
+    pub instructions: Option<Vec<Instruction>>,
+    pub label_to_line: HashMap<String, usize>,
+    pub context: Context,
+}

The runtime structure

+

+ Fields

instructions: Option<Vec<Instruction>>

The script instructions

+
label_to_line: HashMap<String, usize>

Label to line number mapping

+
context: Context

The runtime context

+

Methods

impl Runtime[src]

pub fn new(context: Context) -> Runtime[src]

Creates and returns a new instance.

+

Auto Trait Implementations

impl !Send for Runtime

impl Unpin for Runtime

impl !Sync for Runtime

impl !RefUnwindSafe for Runtime

impl !UnwindSafe for Runtime

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

\ No newline at end of file diff --git a/docs/api/duckscript/duckscript/types/sidebar-items.js b/docs/api/duckscript/duckscript/types/sidebar-items.js new file mode 100644 index 0000000..878e54d --- /dev/null +++ b/docs/api/duckscript/duckscript/types/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"mod":[["command","command"],["error","error"],["instruction","instruction"],["runtime","runtime"]]}); \ No newline at end of file diff --git a/docs/api/duckscript/favicon.ico b/docs/api/duckscript/favicon.ico new file mode 100644 index 0000000..b8ad237 Binary files /dev/null and b/docs/api/duckscript/favicon.ico differ diff --git a/docs/api/duckscript/implementors/core/clone/trait.Clone.js b/docs/api/duckscript/implementors/core/clone/trait.Clone.js new file mode 100644 index 0000000..fa0eeee --- /dev/null +++ b/docs/api/duckscript/implementors/core/clone/trait.Clone.js @@ -0,0 +1,10 @@ +(function() {var implementors = {}; +implementors["duckscript"] = [{text:"impl Clone for GoToValue",synthetic:false,types:["duckscript::types::command::GoToValue"]},{text:"impl Clone for CommandResult",synthetic:false,types:["duckscript::types::command::CommandResult"]},{text:"impl Clone for PreProcessInstruction",synthetic:false,types:["duckscript::types::instruction::PreProcessInstruction"]},{text:"impl Clone for ScriptInstruction",synthetic:false,types:["duckscript::types::instruction::ScriptInstruction"]},{text:"impl Clone for InstructionType",synthetic:false,types:["duckscript::types::instruction::InstructionType"]},{text:"impl Clone for InstructionMetaInfo",synthetic:false,types:["duckscript::types::instruction::InstructionMetaInfo"]},{text:"impl Clone for Instruction",synthetic:false,types:["duckscript::types::instruction::Instruction"]},{text:"impl Clone for StateValue",synthetic:false,types:["duckscript::types::runtime::StateValue"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + +})() diff --git a/docs/api/duckscript/implementors/core/fmt/trait.Debug.js b/docs/api/duckscript/implementors/core/fmt/trait.Debug.js new file mode 100644 index 0000000..7f819b6 --- /dev/null +++ b/docs/api/duckscript/implementors/core/fmt/trait.Debug.js @@ -0,0 +1,10 @@ +(function() {var implementors = {}; +implementors["duckscript"] = [{text:"impl Debug for GoToValue",synthetic:false,types:["duckscript::types::command::GoToValue"]},{text:"impl Debug for CommandResult",synthetic:false,types:["duckscript::types::command::CommandResult"]},{text:"impl Debug for ErrorInfo",synthetic:false,types:["duckscript::types::error::ErrorInfo"]},{text:"impl Debug for ScriptError",synthetic:false,types:["duckscript::types::error::ScriptError"]},{text:"impl Debug for PreProcessInstruction",synthetic:false,types:["duckscript::types::instruction::PreProcessInstruction"]},{text:"impl Debug for ScriptInstruction",synthetic:false,types:["duckscript::types::instruction::ScriptInstruction"]},{text:"impl Debug for InstructionType",synthetic:false,types:["duckscript::types::instruction::InstructionType"]},{text:"impl Debug for InstructionMetaInfo",synthetic:false,types:["duckscript::types::instruction::InstructionMetaInfo"]},{text:"impl Debug for Instruction",synthetic:false,types:["duckscript::types::instruction::Instruction"]},{text:"impl Debug for StateValue",synthetic:false,types:["duckscript::types::runtime::StateValue"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + +})() diff --git a/docs/api/duckscript/implementors/core/fmt/trait.Display.js b/docs/api/duckscript/implementors/core/fmt/trait.Display.js new file mode 100644 index 0000000..8c60b1a --- /dev/null +++ b/docs/api/duckscript/implementors/core/fmt/trait.Display.js @@ -0,0 +1,10 @@ +(function() {var implementors = {}; +implementors["duckscript"] = [{text:"impl Display for ScriptError",synthetic:false,types:["duckscript::types::error::ScriptError"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + +})() diff --git a/docs/api/duckscript/implementors/core/marker/trait.Freeze.js b/docs/api/duckscript/implementors/core/marker/trait.Freeze.js new file mode 100644 index 0000000..1777113 --- /dev/null +++ b/docs/api/duckscript/implementors/core/marker/trait.Freeze.js @@ -0,0 +1,10 @@ +(function() {var implementors = {}; +implementors["duckscript"] = [{text:"impl Freeze for Commands",synthetic:true,types:["duckscript::types::command::Commands"]},{text:"impl Freeze for GoToValue",synthetic:true,types:["duckscript::types::command::GoToValue"]},{text:"impl Freeze for CommandResult",synthetic:true,types:["duckscript::types::command::CommandResult"]},{text:"impl Freeze for ScriptError",synthetic:true,types:["duckscript::types::error::ScriptError"]},{text:"impl Freeze for ErrorInfo",synthetic:true,types:["duckscript::types::error::ErrorInfo"]},{text:"impl Freeze for PreProcessInstruction",synthetic:true,types:["duckscript::types::instruction::PreProcessInstruction"]},{text:"impl Freeze for ScriptInstruction",synthetic:true,types:["duckscript::types::instruction::ScriptInstruction"]},{text:"impl Freeze for InstructionMetaInfo",synthetic:true,types:["duckscript::types::instruction::InstructionMetaInfo"]},{text:"impl Freeze for Instruction",synthetic:true,types:["duckscript::types::instruction::Instruction"]},{text:"impl Freeze for InstructionType",synthetic:true,types:["duckscript::types::instruction::InstructionType"]},{text:"impl Freeze for Context",synthetic:true,types:["duckscript::types::runtime::Context"]},{text:"impl Freeze for Runtime",synthetic:true,types:["duckscript::types::runtime::Runtime"]},{text:"impl Freeze for StateValue",synthetic:true,types:["duckscript::types::runtime::StateValue"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + +})() diff --git a/docs/api/duckscript/implementors/core/marker/trait.Send.js b/docs/api/duckscript/implementors/core/marker/trait.Send.js new file mode 100644 index 0000000..a572793 --- /dev/null +++ b/docs/api/duckscript/implementors/core/marker/trait.Send.js @@ -0,0 +1,10 @@ +(function() {var implementors = {}; +implementors["duckscript"] = [{text:"impl !Send for Commands",synthetic:true,types:["duckscript::types::command::Commands"]},{text:"impl Send for GoToValue",synthetic:true,types:["duckscript::types::command::GoToValue"]},{text:"impl Send for CommandResult",synthetic:true,types:["duckscript::types::command::CommandResult"]},{text:"impl Send for ScriptError",synthetic:true,types:["duckscript::types::error::ScriptError"]},{text:"impl Send for ErrorInfo",synthetic:true,types:["duckscript::types::error::ErrorInfo"]},{text:"impl Send for PreProcessInstruction",synthetic:true,types:["duckscript::types::instruction::PreProcessInstruction"]},{text:"impl Send for ScriptInstruction",synthetic:true,types:["duckscript::types::instruction::ScriptInstruction"]},{text:"impl Send for InstructionMetaInfo",synthetic:true,types:["duckscript::types::instruction::InstructionMetaInfo"]},{text:"impl Send for Instruction",synthetic:true,types:["duckscript::types::instruction::Instruction"]},{text:"impl Send for InstructionType",synthetic:true,types:["duckscript::types::instruction::InstructionType"]},{text:"impl !Send for Context",synthetic:true,types:["duckscript::types::runtime::Context"]},{text:"impl !Send for Runtime",synthetic:true,types:["duckscript::types::runtime::Runtime"]},{text:"impl Send for StateValue",synthetic:true,types:["duckscript::types::runtime::StateValue"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + +})() diff --git a/docs/api/duckscript/implementors/core/marker/trait.Sync.js b/docs/api/duckscript/implementors/core/marker/trait.Sync.js new file mode 100644 index 0000000..7496697 --- /dev/null +++ b/docs/api/duckscript/implementors/core/marker/trait.Sync.js @@ -0,0 +1,10 @@ +(function() {var implementors = {}; +implementors["duckscript"] = [{text:"impl !Sync for Commands",synthetic:true,types:["duckscript::types::command::Commands"]},{text:"impl Sync for GoToValue",synthetic:true,types:["duckscript::types::command::GoToValue"]},{text:"impl Sync for CommandResult",synthetic:true,types:["duckscript::types::command::CommandResult"]},{text:"impl Sync for ScriptError",synthetic:true,types:["duckscript::types::error::ScriptError"]},{text:"impl Sync for ErrorInfo",synthetic:true,types:["duckscript::types::error::ErrorInfo"]},{text:"impl Sync for PreProcessInstruction",synthetic:true,types:["duckscript::types::instruction::PreProcessInstruction"]},{text:"impl Sync for ScriptInstruction",synthetic:true,types:["duckscript::types::instruction::ScriptInstruction"]},{text:"impl Sync for InstructionMetaInfo",synthetic:true,types:["duckscript::types::instruction::InstructionMetaInfo"]},{text:"impl Sync for Instruction",synthetic:true,types:["duckscript::types::instruction::Instruction"]},{text:"impl Sync for InstructionType",synthetic:true,types:["duckscript::types::instruction::InstructionType"]},{text:"impl !Sync for Context",synthetic:true,types:["duckscript::types::runtime::Context"]},{text:"impl !Sync for Runtime",synthetic:true,types:["duckscript::types::runtime::Runtime"]},{text:"impl Sync for StateValue",synthetic:true,types:["duckscript::types::runtime::StateValue"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + +})() diff --git a/docs/api/duckscript/implementors/core/marker/trait.Unpin.js b/docs/api/duckscript/implementors/core/marker/trait.Unpin.js new file mode 100644 index 0000000..e5abb27 --- /dev/null +++ b/docs/api/duckscript/implementors/core/marker/trait.Unpin.js @@ -0,0 +1,10 @@ +(function() {var implementors = {}; +implementors["duckscript"] = [{text:"impl Unpin for Commands",synthetic:true,types:["duckscript::types::command::Commands"]},{text:"impl Unpin for GoToValue",synthetic:true,types:["duckscript::types::command::GoToValue"]},{text:"impl Unpin for CommandResult",synthetic:true,types:["duckscript::types::command::CommandResult"]},{text:"impl Unpin for ScriptError",synthetic:true,types:["duckscript::types::error::ScriptError"]},{text:"impl Unpin for ErrorInfo",synthetic:true,types:["duckscript::types::error::ErrorInfo"]},{text:"impl Unpin for PreProcessInstruction",synthetic:true,types:["duckscript::types::instruction::PreProcessInstruction"]},{text:"impl Unpin for ScriptInstruction",synthetic:true,types:["duckscript::types::instruction::ScriptInstruction"]},{text:"impl Unpin for InstructionMetaInfo",synthetic:true,types:["duckscript::types::instruction::InstructionMetaInfo"]},{text:"impl Unpin for Instruction",synthetic:true,types:["duckscript::types::instruction::Instruction"]},{text:"impl Unpin for InstructionType",synthetic:true,types:["duckscript::types::instruction::InstructionType"]},{text:"impl Unpin for Context",synthetic:true,types:["duckscript::types::runtime::Context"]},{text:"impl Unpin for Runtime",synthetic:true,types:["duckscript::types::runtime::Runtime"]},{text:"impl Unpin for StateValue",synthetic:true,types:["duckscript::types::runtime::StateValue"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + +})() diff --git a/docs/api/duckscript/implementors/std/panic/trait.RefUnwindSafe.js b/docs/api/duckscript/implementors/std/panic/trait.RefUnwindSafe.js new file mode 100644 index 0000000..3338733 --- /dev/null +++ b/docs/api/duckscript/implementors/std/panic/trait.RefUnwindSafe.js @@ -0,0 +1,10 @@ +(function() {var implementors = {}; +implementors["duckscript"] = [{text:"impl !RefUnwindSafe for Commands",synthetic:true,types:["duckscript::types::command::Commands"]},{text:"impl RefUnwindSafe for GoToValue",synthetic:true,types:["duckscript::types::command::GoToValue"]},{text:"impl RefUnwindSafe for CommandResult",synthetic:true,types:["duckscript::types::command::CommandResult"]},{text:"impl !RefUnwindSafe for ScriptError",synthetic:true,types:["duckscript::types::error::ScriptError"]},{text:"impl !RefUnwindSafe for ErrorInfo",synthetic:true,types:["duckscript::types::error::ErrorInfo"]},{text:"impl RefUnwindSafe for PreProcessInstruction",synthetic:true,types:["duckscript::types::instruction::PreProcessInstruction"]},{text:"impl RefUnwindSafe for ScriptInstruction",synthetic:true,types:["duckscript::types::instruction::ScriptInstruction"]},{text:"impl RefUnwindSafe for InstructionMetaInfo",synthetic:true,types:["duckscript::types::instruction::InstructionMetaInfo"]},{text:"impl RefUnwindSafe for Instruction",synthetic:true,types:["duckscript::types::instruction::Instruction"]},{text:"impl RefUnwindSafe for InstructionType",synthetic:true,types:["duckscript::types::instruction::InstructionType"]},{text:"impl !RefUnwindSafe for Context",synthetic:true,types:["duckscript::types::runtime::Context"]},{text:"impl !RefUnwindSafe for Runtime",synthetic:true,types:["duckscript::types::runtime::Runtime"]},{text:"impl RefUnwindSafe for StateValue",synthetic:true,types:["duckscript::types::runtime::StateValue"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + +})() diff --git a/docs/api/duckscript/implementors/std/panic/trait.UnwindSafe.js b/docs/api/duckscript/implementors/std/panic/trait.UnwindSafe.js new file mode 100644 index 0000000..c1b0ff9 --- /dev/null +++ b/docs/api/duckscript/implementors/std/panic/trait.UnwindSafe.js @@ -0,0 +1,10 @@ +(function() {var implementors = {}; +implementors["duckscript"] = [{text:"impl !UnwindSafe for Commands",synthetic:true,types:["duckscript::types::command::Commands"]},{text:"impl UnwindSafe for GoToValue",synthetic:true,types:["duckscript::types::command::GoToValue"]},{text:"impl UnwindSafe for CommandResult",synthetic:true,types:["duckscript::types::command::CommandResult"]},{text:"impl !UnwindSafe for ScriptError",synthetic:true,types:["duckscript::types::error::ScriptError"]},{text:"impl !UnwindSafe for ErrorInfo",synthetic:true,types:["duckscript::types::error::ErrorInfo"]},{text:"impl UnwindSafe for PreProcessInstruction",synthetic:true,types:["duckscript::types::instruction::PreProcessInstruction"]},{text:"impl UnwindSafe for ScriptInstruction",synthetic:true,types:["duckscript::types::instruction::ScriptInstruction"]},{text:"impl UnwindSafe for InstructionMetaInfo",synthetic:true,types:["duckscript::types::instruction::InstructionMetaInfo"]},{text:"impl UnwindSafe for Instruction",synthetic:true,types:["duckscript::types::instruction::Instruction"]},{text:"impl UnwindSafe for InstructionType",synthetic:true,types:["duckscript::types::instruction::InstructionType"]},{text:"impl !UnwindSafe for Context",synthetic:true,types:["duckscript::types::runtime::Context"]},{text:"impl !UnwindSafe for Runtime",synthetic:true,types:["duckscript::types::runtime::Runtime"]},{text:"impl UnwindSafe for StateValue",synthetic:true,types:["duckscript::types::runtime::StateValue"]},]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + +})() diff --git a/docs/api/duckscript/light.css b/docs/api/duckscript/light.css new file mode 100644 index 0000000..52bbbce --- /dev/null +++ b/docs/api/duckscript/light.css @@ -0,0 +1 @@ + body{background-color:white;color:black;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){color:black;}h1.fqn{border-bottom-color:#D5D5D5;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){border-bottom-color:#DDDDDD;}.in-band{background-color:white;}.invisible{background:rgba(0,0,0,0);}.docblock code,.docblock-short code{background-color:#F5F5F5;}pre{background-color:#F5F5F5;}.sidebar{background-color:#F1F1F1;}.sidebar .current{background-color:#fff;}.source .sidebar{background-color:#fff;}.sidebar .location{border-color:#000;background-color:#fff;color:#333;}.sidebar .version{border-bottom-color:#DDD;}.sidebar-title{border-top-color:#777;border-bottom-color:#777;}.block a:hover{background:#F5F5F5;}.line-numbers span{color:#c67e2d;}.line-numbers .line-highlighted{background-color:#f6fdb0 !important;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom-color:#ddd;}.docblock table,.docblock table td,.docblock table th{border-color:#ddd;}.content .method .where,.content .fn .where,.content .where.fmt-newline{color:#4E4C4C;}.content .highlighted{color:#000 !important;background-color:#ccc;}.content .highlighted a,.content .highlighted span{color:#000 !important;}.content .highlighted.trait{background-color:#c7b6ff;}.content .highlighted.traitalias{background-color:#c7b6ff;}.content .highlighted.mod,.content .highlighted.externcrate{background-color:#afc6e4;}.content .highlighted.enum{background-color:#b4d1b9;}.content .highlighted.struct{background-color:#e7b1a0;}.content .highlighted.union{background-color:#b7bd49;}.content .highlighted.fn,.content .highlighted.method,.content .highlighted.tymethod{background-color:#c6afb3;}.content .highlighted.type{background-color:#ffc891;}.content .highlighted.foreigntype{background-color:#f5c4ff;}.content .highlighted.attr,.content .highlighted.derive,.content .highlighted.macro{background-color:#8ce488;}.content .highlighted.constant,.content .highlighted.static{background-color:#c3e0ff;}.content .highlighted.primitive{background-color:#9aecff;}.content .highlighted.keyword{background-color:#f99650;}.content span.enum,.content a.enum,.block a.current.enum{color:#508157;}.content span.struct,.content a.struct,.block a.current.struct{color:#ad448e;}.content span.type,.content a.type,.block a.current.type{color:#ba5d00;}.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype{color:#cd00e2;}.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro{color:#068000;}.content span.union,.content a.union,.block a.current.union{color:#767b27;}.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static{color:#546e8a;}.content span.primitive,.content a.primitive,.block a.current.primitive{color:#2c8093;}.content span.externcrate,.content span.mod,.content a.mod,.block a.current.mod{color:#4d76ae;}.content span.trait,.content a.trait,.block a.current.trait{color:#7c5af3;}.content span.traitalias,.content a.traitalias,.block a.current.traitalias{color:#6841f1;}.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname{color:#9a6e31;}.content span.keyword,.content a.keyword,.block a.current.keyword{color:#de5249;}pre.rust .comment{color:#8E908C;}pre.rust .doccomment{color:#4D4D4C;}nav{border-bottom-color:#e0e0e0;}nav.main .current{border-top-color:#000;border-bottom-color:#000;}nav.main .separator{border:1px solid #000;}a{color:#000;}.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow),.docblock-short a:not(.srclink):not(.test-arrow),.stability a{color:#3873AD;}.stab.internal a{color:#304FFE;}a.test-arrow{color:#f5f5f5;}.collapse-toggle{color:#999;}#crate-search{color:#555;background-color:white;border-color:#e0e0e0;box-shadow:0 0 0 1px #e0e0e0,0 0 0 2px transparent;}.search-input{color:#555;background-color:white;box-shadow:0 0 0 1px #e0e0e0,0 0 0 2px transparent;}.search-input:focus{border-color:#66afe9;}#crate-search+.search-input:focus{box-shadow:0 0 8px #078dd8;}.module-item .stab{color:#000;}.stab.unstable{background:#FFF5D6;border-color:#FFC600;}.stab.internal{background:#FFB9B3;border-color:#B71C1C;}.stab.deprecated{background:#F3DFFF;border-color:#7F0087;}.stab.portability{background:#C4ECFF;border-color:#7BA5DB;}.stab.portability>code{color:#000;}#help>div{background:#e9e9e9;border-color:#bfbfbf;}.since{color:grey;}tr.result span.primitive::after,tr.result span.keyword::after{color:black;}.line-numbers :target{background-color:transparent;}pre.rust .kw{color:#8959A8;}pre.rust .kw-2,pre.rust .prelude-ty{color:#4271AE;}pre.rust .number,pre.rust .string{color:#718C00;}pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident{color:#C82829;}pre.rust .macro,pre.rust .macro-nonterminal{color:#3E999F;}pre.rust .lifetime{color:#B76514;}pre.rust .question-mark{color:#ff9011;}.example-wrap>pre.line-number{border-color:#c7c7c7;}a.test-arrow{background-color:rgba(78,139,202,0.2);}a.test-arrow:hover{background-color:#4e8bca;}.toggle-label{color:#999;}:target>code,:target>.in-band{background:#FDFFD3;}pre.compile_fail{border-left:2px solid rgba(255,0,0,.4);}pre.compile_fail:hover,.information:hover+pre.compile_fail{border-left:2px solid #f00;}pre.ignore{border-left:2px solid rgba(255,142,0,.4);}pre.ignore:hover,.information:hover+pre.ignore{border-left:2px solid #ff9200;}.tooltip.compile_fail{color:rgba(255,0,0,.3);}.information>.compile_fail:hover{color:#f00;}.tooltip.ignore{color:rgba(255,142,0,.3);}.information>.ignore:hover{color:rgba(255,142,0,1);}.search-failed a{color:#0089ff;}.tooltip .tooltiptext{background-color:black;color:#fff;}.tooltip .tooltiptext::after{border-color:transparent black transparent transparent;}.important-traits .tooltip .tooltiptext{background-color:white;color:black;border-color:black;}#titles>div:not(.selected){background-color:#e6e6e6;border-top-color:#e6e6e6;}#titles>div:hover,#titles>div.selected{border-top-color:#0089ff;}#titles>div>div.count{color:#888;}.modal{background-color:rgba(0,0,0,0.3);}.modal-content{background-color:#eee;border-color:#999;}.modal-content>.close{background-color:#eee;border-color:#999;}.modal-content>.close:hover{background-color:#ff1f1f;color:white;}.modal-content>.whiter{background-color:#eee;}.modal-content>.close:hover+.whiter{background-color:#ff1f1f;}@media (max-width:700px){.sidebar-menu{background-color:#F1F1F1;border-bottom-color:#e0e0e0;border-right-color:#e0e0e0;}.sidebar-elems{background-color:#F1F1F1;border-right-color:#000;}#sidebar-filler{background-color:#F1F1F1;border-bottom-color:#e0e0e0;}}kbd{color:#000;background-color:#fafbfc;border-color:#d1d5da;border-bottom-color:#c6cbd1;box-shadow-color:#c6cbd1;}#theme-picker,#settings-menu{border-color:#e0e0e0;background-color:#fff;}#theme-picker:hover,#theme-picker:focus,#settings-menu:hover,#settings-menu:focus{border-color:#717171;}#theme-choices{border-color:#ccc;background-color:#fff;}#theme-choices>button:not(:first-child){border-top-color:#e0e0e0;}#theme-choices>button:hover,#theme-choices>button:focus{background-color:#eee;}@media (max-width:700px){#theme-picker{background:#fff;}}#all-types{background-color:#fff;}#all-types:hover{background-color:#f9f9f9;}.search-results td span.alias{color:#000;}.search-results td span.grey{color:#999;}#sidebar-toggle{background-color:#F1F1F1;}#sidebar-toggle:hover{background-color:#E0E0E0;}#source-sidebar{background-color:#F1F1F1;}#source-sidebar>.title{border-bottom-color:#ccc;}div.files>a:hover,div.name:hover{background-color:#E0E0E0;}div.files>.selected{background-color:#fff;} \ No newline at end of file diff --git a/docs/api/duckscript/main.js b/docs/api/duckscript/main.js new file mode 100644 index 0000000..7a19f43 --- /dev/null +++ b/docs/api/duckscript/main.js @@ -0,0 +1,95 @@ +if(!String.prototype.startsWith){String.prototype.startsWith=function(searchString,position){position=position||0;return this.indexOf(searchString,position)===position;};}if(!String.prototype.endsWith){String.prototype.endsWith=function(suffix,length){var l=length||this.length;return this.indexOf(suffix,l-suffix.length)!==-1;};}if(!DOMTokenList.prototype.add){DOMTokenList.prototype.add=function(className){if(className&&!hasClass(this,className)){if(this.className&&this.className.length>0){this.className+=" "+className;}else{this.className=className;}}};}if(!DOMTokenList.prototype.remove){DOMTokenList.prototype.remove=function(className){if(className&&this.className){this.className=(" "+this.className+" ").replace(" "+className+" "," ").trim();}};}(function(){"use strict";var itemTypes=["mod","externcrate","import","struct","enum","fn","type","static","trait","impl","tymethod","method","structfield","variant","macro","primitive","associatedtype","constant","associatedconstant","union","foreigntype","keyword","existential","attr","derive","traitalias"];var search_input=document.getElementsByClassName("search-input")[0];var currentTab=0;var titleBeforeSearch=document.title;function getPageId(){var id=document.location.href.split("#")[1];if(id){return id.split("?")[0].split("&")[0];}return null;}function showSidebar(){var elems=document.getElementsByClassName("sidebar-elems")[0];if(elems){addClass(elems,"show-it");}var sidebar=document.getElementsByClassName("sidebar")[0];if(sidebar){addClass(sidebar,"mobile");var filler=document.getElementById("sidebar-filler");if(!filler){var div=document.createElement("div");div.id="sidebar-filler";sidebar.appendChild(div);}}var themePicker=document.getElementsByClassName("theme-picker");if(themePicker&&themePicker.length>0){themePicker[0].style.display="none";}}function hideSidebar(){var elems=document.getElementsByClassName("sidebar-elems")[0];if(elems){removeClass(elems,"show-it");}var sidebar=document.getElementsByClassName("sidebar")[0];removeClass(sidebar,"mobile");var filler=document.getElementById("sidebar-filler");if(filler){filler.remove();}document.getElementsByTagName("body")[0].style.marginTop="";var themePicker=document.getElementsByClassName("theme-picker");if(themePicker&&themePicker.length>0){themePicker[0].style.display=null;}}var TY_PRIMITIVE=itemTypes.indexOf("primitive");var TY_KEYWORD=itemTypes.indexOf("keyword");onEachLazy(document.getElementsByClassName("js-only"),function(e){removeClass(e,"js-only");});function getQueryStringParams(){var params={};window.location.search.substring(1).split("&").map(function(s){var pair=s.split("=");params[decodeURIComponent(pair[0])]=typeof pair[1]==="undefined"?null:decodeURIComponent(pair[1]);});return params;}function browserSupportsHistoryApi(){return window.history&&typeof window.history.pushState==="function";}var main=document.getElementById("main");function highlightSourceLines(ev){hideSidebar();var elem;var search=document.getElementById("search");var i,from,to,match=window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);if(match){from=parseInt(match[1],10);to=from;if(typeof match[2]!=="undefined"){to=parseInt(match[2],10);}if(to0){collapseDocs(collapses[0],"show");}}}}highlightSourceLines(null);window.onhashchange=highlightSourceLines;function getVirtualKey(ev){if("key"in ev&&typeof ev.key!="undefined"){return ev.key;}var c=ev.charCode||ev.keyCode;if(c==27){return"Escape";}return String.fromCharCode(c);}function displayHelp(display,ev,help){if(display===true){if(hasClass(help,"hidden")){ev.preventDefault();removeClass(help,"hidden");addClass(document.body,"blur");}}else if(hasClass(help,"hidden")===false){ev.preventDefault();addClass(help,"hidden");removeClass(document.body,"blur");}}function handleEscape(ev,help){hideModal();var search=document.getElementById("search");if(hasClass(help,"hidden")===false){displayHelp(false,ev,help);}else if(hasClass(search,"hidden")===false){ev.preventDefault();addClass(search,"hidden");removeClass(main,"hidden");document.title=titleBeforeSearch;}defocusSearchBar();}function handleShortcut(ev){if(ev.ctrlKey||ev.altKey||ev.metaKey){return;}var help=document.getElementById("help");if(document.activeElement.tagName==="INPUT"){switch(getVirtualKey(ev)){case"Escape":handleEscape(ev,help);break;}}else{switch(getVirtualKey(ev)){case"Escape":handleEscape(ev,help);break;case"s":case"S":displayHelp(false,ev,help);hideModal();ev.preventDefault();focusSearchBar();break;case"+":case"-":ev.preventDefault();toggleAllDocs();break;case"?":if(ev.shiftKey){hideModal();displayHelp(true,ev,help);}break;}}}function findParentElement(elem,tagName){do{if(elem&&elem.tagName===tagName){return elem;}elem=elem.parentNode;}while(elem);return null;}document.onkeypress=handleShortcut;document.onkeydown=handleShortcut;document.onclick=function(ev){if(hasClass(ev.target,"collapse-toggle")){collapseDocs(ev.target,"toggle");}else if(hasClass(ev.target.parentNode,"collapse-toggle")){collapseDocs(ev.target.parentNode,"toggle");}else if(ev.target.tagName==="SPAN"&&hasClass(ev.target.parentNode,"line-numbers")){var prev_id=0;var set_fragment=function(name){if(browserSupportsHistoryApi()){history.replaceState(null,null,"#"+name);window.hashchange();}else{location.replace("#"+name);}};var cur_id=parseInt(ev.target.id,10);if(ev.shiftKey&&prev_id){if(prev_id>cur_id){var tmp=prev_id;prev_id=cur_id;cur_id=tmp;}set_fragment(prev_id+"-"+cur_id);}else{prev_id=cur_id;set_fragment(cur_id);}}else if(hasClass(document.getElementById("help"),"hidden")===false){addClass(document.getElementById("help"),"hidden");removeClass(document.body,"blur");}else{var a=findParentElement(ev.target,"A");if(a&&a.hash){expandSection(a.hash.replace(/^#/,""));}}};var x=document.getElementsByClassName("version-selector");if(x.length>0){x[0].onchange=function(){var i,match,url=document.location.href,stripped="",len=rootPath.match(/\.\.\//g).length+1;for(i=0;i-1){var obj=searchIndex[results[i].id];obj.lev=results[i].lev;if(isType!==true||obj.type){var res=buildHrefAndPath(obj);obj.displayPath=pathSplitter(res[0]);obj.fullPath=obj.displayPath+obj.name;obj.fullPath+="|"+obj.ty;obj.href=res[1];out.push(obj);if(out.length>=MAX_RESULTS){break;}}}}return out;}function sortResults(results,isType){var ar=[];for(var entry in results){if(results.hasOwnProperty(entry)){ar.push(results[entry]);}}results=ar;var i;var nresults=results.length;for(i=0;ib?+1:-1);}a=(aaa.index<0);b=(bbb.index<0);if(a!==b){return a-b;}a=aaa.index;b=bbb.index;if(a!==b){return a-b;}if((aaa.item.ty===TY_PRIMITIVE&&bbb.item.ty!==TY_KEYWORD)||(aaa.item.ty===TY_KEYWORD&&bbb.item.ty!==TY_PRIMITIVE)){return-1;}if((bbb.item.ty===TY_PRIMITIVE&&aaa.item.ty!==TY_PRIMITIVE)||(bbb.item.ty===TY_KEYWORD&&aaa.item.ty!==TY_KEYWORD)){return 1;}a=(aaa.item.desc==="");b=(bbb.item.desc==="");if(a!==b){return a-b;}a=aaa.item.ty;b=bbb.item.ty;if(a!==b){return a-b;}a=aaa.item.path;b=bbb.item.path;if(a!==b){return(a>b?+1:-1);}return 0;});var length=results.length;for(i=0;i"));return{name:val.substring(0,val.indexOf("<")),generics:values.split(/\s*,\s*/),};}return{name:val,generics:[],};}function checkGenerics(obj,val){var lev_distance=MAX_LEV_DISTANCE+1;if(val.generics.length>0){if(obj.length>GENERICS_DATA&&obj[GENERICS_DATA].length>=val.generics.length){var elems=obj[GENERICS_DATA].slice(0);var total=0;var done=0;var vlength=val.generics.length;for(var y=0;yGENERICS_DATA&&obj[GENERICS_DATA].length>=val.generics.length){var elems=obj[GENERICS_DATA].slice(0);var allFound=true;for(var y=0;allFound===true&&yGENERICS_DATA&&obj[GENERICS_DATA].length!==0){var tmp_lev=checkGenerics(obj,val);if(tmp_lev<=MAX_LEV_DISTANCE){return tmp_lev;}}else{return 0;}}if(literalSearch===true){if(obj.length>GENERICS_DATA&&obj[GENERICS_DATA].length>0){var length=obj[GENERICS_DATA].length;for(x=0;x GENERICS_DATA && obj[GENERICS_DATA].length > 0) { + // We can check if the type we're looking for is inside the generics! + var olength = obj[GENERICS_DATA].length; + for (x = 0; x < olength; ++x) { + lev_distance = Math.min(levenshtein(obj[GENERICS_DATA][x], val.name), + lev_distance); + } + } + // Now whatever happens, the returned distance is "less good" so we should mark it + // as such, and so we add 1 to the distance to make it "less good". + return lev_distance + 1; + } + + function findArg(obj, val, literalSearch) { + var lev_distance = MAX_LEV_DISTANCE + 1; + + if (obj && obj.type && obj.type[INPUTS_DATA] && + obj.type[INPUTS_DATA].length > 0) { + var length = obj.type[INPUTS_DATA].length; + for (var i = 0; i < length; i++) { + var tmp = checkType(obj.type[INPUTS_DATA][i], val, literalSearch); + if (literalSearch === true && tmp === true) { + return true; + } + lev_distance = Math.min(tmp, lev_distance); + if (lev_distance === 0) { + return 0; + } + } + } + return literalSearch === true ? false : lev_distance; + } + + function checkReturned(obj, val, literalSearch) { + var lev_distance = MAX_LEV_DISTANCE + 1; + + if (obj && obj.type && obj.type.length > OUTPUT_DATA) { + var ret = obj.type[OUTPUT_DATA]; + if (!obj.type[OUTPUT_DATA].length) { + ret = [ret]; + } + for (var x = 0; x < ret.length; ++x) { + var r = ret[x]; + if (typeof r === "string") { + r = [r]; + } + var tmp = checkType(r, val, literalSearch); + if (literalSearch === true) { + if (tmp === true) { + return true; + } + continue; + } + lev_distance = Math.min(tmp, lev_distance); + if (lev_distance === 0) { + return 0; + } + } + } + return literalSearch === true ? false : lev_distance; + } + + function checkPath(contains, lastElem, ty) { + if (contains.length === 0) { + return 0; + } + var ret_lev = MAX_LEV_DISTANCE + 1; + var path = ty.path.split("::"); + + if (ty.parent && ty.parent.name) { + path.push(ty.parent.name.toLowerCase()); + } + + var length = path.length; + var clength = contains.length; + if (clength > length) { + return MAX_LEV_DISTANCE + 1; + } + for (var i = 0; i < length; ++i) { + if (i + clength > length) { + break; + } + var lev_total = 0; + var aborted = false; + for (var x = 0; x < clength; ++x) { + var lev = levenshtein(path[i + x], contains[x]); + if (lev > MAX_LEV_DISTANCE) { + aborted = true; + break; + } + lev_total += lev; + } + if (aborted === false) { + ret_lev = Math.min(ret_lev, Math.round(lev_total /clength));}}return ret_lev;}function typePassesFilter(filter,type){if(filter<0)return true;if(filter===type)return true;var name=itemTypes[type];switch(itemTypes[filter]){case"constant":return(name=="associatedconstant");case"fn":return(name=="method"||name=="tymethod");case"type":return(name=="primitive"||name=="keyword");}return false;}function generateId(ty){if(ty.parent&&ty.parent.name){return itemTypes[ty.ty]+ty.path+ty.parent.name+ty.name;}return itemTypes[ty.ty]+ty.path+ty.name;}var nSearchWords=searchWords.length;var i;var ty;var fullId;var returned;var in_args;if((val.charAt(0)==="\""||val.charAt(0)==="'")&&val.charAt(val.length-1)===val.charAt(0)){val=extractGenerics(val.substr(1,val.length-2));for(i=0;i")>-1){var trimmer=function(s){return s.trim();};var parts=val.split("->").map(trimmer);var input=parts[0];var inputs=input.split(",").map(trimmer).sort();for(i=0;iOUTPUT_DATA?type[OUTPUT_DATA].name:"";returned=checkReturned(ty,output,true);if(output.name==="*"||returned===true){in_args=false;var is_module=false;if(input==="*"){is_module=true;}else{var allFound=true;for(var it=0;allFound===true&&it1?paths.length-1:1);for(j=0;j1){lev=checkPath(contains,paths[paths.length-1],ty);if(lev>MAX_LEV_DISTANCE){continue;}else if(lev>0){lev_add=1;}}returned=MAX_LEV_DISTANCE+1;in_args=MAX_LEV_DISTANCE+1;var index=-1;lev=MAX_LEV_DISTANCE+1;fullId=generateId(ty);if(searchWords[j].indexOf(split[i])>-1||searchWords[j].indexOf(val)>-1||searchWords[j].replace(/_/g,"").indexOf(val)>-1){if(typePassesFilter(typeFilter,ty.ty)&&results[fullId]===undefined){index=searchWords[j].replace(/_/g,"").indexOf(val);}}if((lev=levenshtein(searchWords[j],val))<=MAX_LEV_DISTANCE){if(typePassesFilter(typeFilter,ty.ty)===false){lev=MAX_LEV_DISTANCE+1;}else{lev+=1;}}if((in_args=findArg(ty,valGenerics))<=MAX_LEV_DISTANCE){if(typePassesFilter(typeFilter,ty.ty)===false){in_args=MAX_LEV_DISTANCE+1;}}if((returned=checkReturned(ty,valGenerics))<=MAX_LEV_DISTANCE){if(typePassesFilter(typeFilter,ty.ty)===false){returned=MAX_LEV_DISTANCE+1;}}lev+=lev_add;if(lev>0&&val.length>3&&searchWords[j].indexOf(val)>-1){if(val.length<6){lev-=1;}else{lev=0;}}if(in_args<=MAX_LEV_DISTANCE){if(results_in_args[fullId]===undefined){results_in_args[fullId]={id:j,index:index,lev:in_args,};}results_in_args[fullId].lev=Math.min(results_in_args[fullId].lev,in_args);}if(returned<=MAX_LEV_DISTANCE){if(results_returned[fullId]===undefined){results_returned[fullId]={id:j,index:index,lev:returned,};}results_returned[fullId].lev=Math.min(results_returned[fullId].lev,returned);}if(index!==-1||lev<=MAX_LEV_DISTANCE){if(index!==-1&&paths.length<2){lev=0;}else if(searchWords[j]===val){lev=-1;}if(results[fullId]===undefined){results[fullId]={id:j,index:index,lev:lev,};}results[fullId].lev=Math.min(results[fullId].lev,lev);}}}var ret={"in_args":sortResults(results_in_args,true),"returned":sortResults(results_returned,true),"others":sortResults(results),};if(ALIASES&&ALIASES[window.currentCrate]&&ALIASES[window.currentCrate][query.raw]){var aliases=ALIASES[window.currentCrate][query.raw];for(i=0;iMAX_RESULTS){ret.others.pop();}}}return ret;}function validateResult(name,path,keys,parent){for(var i=0;i-1||path.indexOf(keys[i])>-1||(parent!==undefined&&parent.name.toLowerCase().indexOf(keys[i])>-1)||levenshtein(name,keys[i])<=MAX_LEV_DISTANCE)){return false;}}return true;}function getQuery(raw){var matches,type,query;query=raw;matches=query.match(/^(fn|mod|struct|enum|trait|type|const|macro)\s*:\s*/i);if(matches){type=matches[1].replace(/^const$/,"constant");query=query.substring(matches[0].length);}return{raw:raw,query:query,type:type,id:query+type};}function initSearchNav(){var hoverTimeout;var click_func=function(e){var el=e.target;while(el.tagName!=="TR"){el=el.parentNode;}var dst=e.target.getElementsByTagName("a");if(dst.length<1){return;}dst=dst[0];if(window.location.pathname===dst.pathname){addClass(document.getElementById("search"),"hidden");removeClass(main,"hidden");document.location.href=dst.href;}};var mouseover_func=function(e){var el=e.target;while(el.tagName!=="TR"){el=el.parentNode;}clearTimeout(hoverTimeout);hoverTimeout=setTimeout(function(){onEachLazy(document.getElementsByClassName("search-results"),function(e){onEachLazy(e.getElementsByClassName("result"),function(i_e){removeClass(i_e,"highlighted");});});addClass(el,"highlighted");},20);};onEachLazy(document.getElementsByClassName("search-results"),function(e){onEachLazy(e.getElementsByClassName("result"),function(i_e){i_e.onclick=click_func;i_e.onmouseover=mouseover_func;});});search_input.onkeydown=function(e){var actives=[[],[],[]];var current=0;onEachLazy(document.getElementById("results").childNodes,function(e){onEachLazy(e.getElementsByClassName("highlighted"),function(e){actives[current].push(e);});current+=1;});if(e.which===38){if(!actives[currentTab].length||!actives[currentTab][0].previousElementSibling){return;}addClass(actives[currentTab][0].previousElementSibling,"highlighted");removeClass(actives[currentTab][0],"highlighted");}else if(e.which===40){if(!actives[currentTab].length){var results=document.getElementById("results").childNodes;if(results.length>0){var res=results[currentTab].getElementsByClassName("result");if(res.length>0){addClass(res[0],"highlighted");}}}else if(actives[currentTab][0].nextElementSibling){addClass(actives[currentTab][0].nextElementSibling,"highlighted");removeClass(actives[currentTab][0],"highlighted");}}else if(e.which===13){if(actives[currentTab].length){document.location.href=actives[currentTab][0].getElementsByTagName("a")[0].href;}}else if(e.which===9){if(e.shiftKey){printTab(currentTab>0?currentTab-1:2);}else{printTab(currentTab>1?0:currentTab+1);}e.preventDefault();}else if(e.which===16){}else if(e.which===27){removeClass(actives[currentTab][0],"highlighted");search_input.value="";defocusSearchBar();}else if(actives[currentTab].length>0){removeClass(actives[currentTab][0],"highlighted");}};}function buildHrefAndPath(item){var displayPath;var href;var type=itemTypes[item.ty];var name=item.name;if(type==="mod"){displayPath=item.path+"::";href=rootPath+item.path.replace(/::/g,"/")+"/"+name+"/index.html";}else if(type==="primitive"||type==="keyword"){displayPath="";href=rootPath+item.path.replace(/::/g,"/")+"/"+type+"."+name+".html";}else if(type==="externcrate"){displayPath="";href=rootPath+name+"/index.html";}else if(item.parent!==undefined){var myparent=item.parent;var anchor="#"+type+"."+name;var parentType=itemTypes[myparent.ty];if(parentType==="primitive"){displayPath=myparent.name+"::";}else{displayPath=item.path+"::"+myparent.name+"::";}href=rootPath+item.path.replace(/::/g,"/")+"/"+parentType+"."+myparent.name+".html"+anchor;}else{displayPath=item.path+"::";href=rootPath+item.path.replace(/::/g,"/")+"/"+type+"."+name+".html";}return[displayPath,href];}function escape(content){var h1=document.createElement("h1");h1.textContent=content;return h1.innerHTML;}function pathSplitter(path){var tmp=""+path.replace(/::/g,"::");if(tmp.endsWith("")){return tmp.slice(0,tmp.length-6);}return tmp;}function addTab(array,query,display){var extraStyle="";if(display===false){extraStyle=" style=\"display: none;\"";}var output="";var duplicates={};var length=0;if(array.length>0){output="";array.forEach(function(item){var name,type;name=item.name;type=itemTypes[item.ty];if(item.is_alias!==true){if(duplicates[item.fullPath]){return;}duplicates[item.fullPath]=true;}length+=1;output+="";});output+="
"+""+(item.is_alias===true?(""+item.alias+"  - see "):"")+item.displayPath+""+name+""+""+""+escape(item.desc)+" 
";}else{output="
No results :(
"+"Try on DuckDuckGo?

"+"Or try looking in one of these:
";}return[output,length];}function makeTabHeader(tabNb,text,nbElems){if(currentTab===tabNb){return"
"+text+"
("+nbElems+")
";}return"
"+text+"
("+nbElems+")
";}function showResults(results){if(results.others.length===1&&getCurrentValue("rustdoc-go-to-only-result")==="true"){var elem=document.createElement("a");elem.href=results.others[0].href;elem.style.display="none";document.body.appendChild(elem);elem.click();}var query=getQuery(search_input.value);currentResults=query.id;var ret_others=addTab(results.others,query);var ret_in_args=addTab(results.in_args,query,false);var ret_returned=addTab(results.returned,query,false);var output="

Results for "+escape(query.query)+(query.type?" (type: "+escape(query.type)+")":"")+"

"+"
"+makeTabHeader(0,"In Names",ret_others[1])+makeTabHeader(1,"In Parameters",ret_in_args[1])+makeTabHeader(2,"In Return Types",ret_returned[1])+"
"+ret_others[0]+ret_in_args[0]+ret_returned[0]+"
";addClass(main,"hidden");var search=document.getElementById("search");removeClass(search,"hidden");search.innerHTML=output;var tds=search.getElementsByTagName("td");var td_width=0;if(tds.length>0){td_width=tds[0].offsetWidth;}var width=search.offsetWidth-40-td_width;onEachLazy(search.getElementsByClassName("desc"),function(e){e.style.width=width+"px";});initSearchNav();var elems=document.getElementById("titles").childNodes;elems[0].onclick=function(){printTab(0);};elems[1].onclick=function(){printTab(1);};elems[2].onclick=function(){printTab(2);};printTab(currentTab);}function execSearch(query,searchWords,filterCrates){function getSmallest(arrays,positions,notDuplicates){var start=null;for(var it=0;itpositions[it]&&(start===null||start>arrays[it][positions[it]].lev)&&!notDuplicates[arrays[it][positions[it]].fullPath]){start=arrays[it][positions[it]].lev;}}return start;}function mergeArrays(arrays){var ret=[];var positions=[];var notDuplicates={};for(var x=0;xpositions[x]&&arrays[x][positions[x]].lev===smallest&&!notDuplicates[arrays[x][positions[x]].fullPath]){ret.push(arrays[x][positions[x]]);notDuplicates[arrays[x][positions[x]].fullPath]=true;positions[x]+=1;}}}return ret;}var queries=query.raw.split(",");var results={"in_args":[],"returned":[],"others":[],};for(var i=0;i1){return{"in_args":mergeArrays(results.in_args),"returned":mergeArrays(results.returned),"others":mergeArrays(results.others),};}else{return{"in_args":results.in_args[0],"returned":results.returned[0],"others":results.others[0],};}}function getFilterCrates(){var elem=document.getElementById("crate-search");if(elem&&elem.value!=="All crates"&&rawSearchIndex.hasOwnProperty(elem.value)){return elem.value;}return undefined;}function search(e,forced){var params=getQueryStringParams();var query=getQuery(search_input.value.trim());if(e){e.preventDefault();}if(query.query.length===0){return;}if(forced!==true&&query.id===currentResults){if(query.query.length>0){putBackSearch(search_input);}return;}document.title="Results for "+query.query+" - Rust";if(browserSupportsHistoryApi()){if(!history.state&&!params.search){history.pushState(query,"","?search="+encodeURIComponent(query.raw));}else{history.replaceState(query,"","?search="+encodeURIComponent(query.raw));}}var filterCrates=getFilterCrates();showResults(execSearch(query,index,filterCrates),filterCrates);}function buildIndex(rawSearchIndex){searchIndex=[];var searchWords=[];var i;for(var crate in rawSearchIndex){if(!rawSearchIndex.hasOwnProperty(crate)){continue;}searchWords.push(crate);searchIndex.push({crate:crate,ty:1,name:crate,path:"",desc:rawSearchIndex[crate].doc,type:null,});var items=rawSearchIndex[crate].i;var paths=rawSearchIndex[crate].p;var len=paths.length;for(i=0;i"+""+"
"+code.outerHTML+"
";list.appendChild(display);}}};if(window.pending_implementors){window.register_implementors(window.pending_implementors);}function labelForToggleButton(sectionIsCollapsed){if(sectionIsCollapsed){return"+";}return"\u2212";}function onEveryMatchingChild(elem,className,func){if(elem&&className&&func){var length=elem.childNodes.length;var nodes=elem.childNodes;for(var i=0;i"+labelForToggleButton(sectionIsCollapsed)+"
]";return toggle;}var toggle=createSimpleToggle(false);var hideMethodDocs=getCurrentValue("rustdoc-method-docs")==="true";var pageId=getPageId();var func=function(e){var next=e.nextElementSibling;if(!next){return;}if(hasClass(next,"docblock")===true||(hasClass(next,"stability")===true&&hasClass(next.nextElementSibling,"docblock")===true)){var newToggle=toggle.cloneNode(true);insertAfter(newToggle,e.childNodes[e.childNodes.length-1]);if(hideMethodDocs===true&&hasClass(e,"method")===true){collapseDocs(newToggle,"hide",pageId);}}};var funcImpl=function(e){var next=e.nextElementSibling;if(next&&hasClass(next,"docblock")){next=next.nextElementSibling;}if(!next){return;}if(next.getElementsByClassName("method").length>0&&hasClass(e,"impl")){insertAfter(toggle.cloneNode(true),e.childNodes[e.childNodes.length-1]);}};onEachLazy(document.getElementsByClassName("method"),func);onEachLazy(document.getElementsByClassName("associatedconstant"),func);onEachLazy(document.getElementsByClassName("impl"),funcImpl);var impl_call=function(){};if(hideMethodDocs===true){impl_call=function(e,newToggle,pageId){if(e.id.match(/^impl(?:-\d+)?$/)===null){if(hasClass(e,"impl")===true){collapseDocs(newToggle,"hide",pageId);}}};}var newToggle=document.createElement("a");newToggle.href="javascript:void(0)";newToggle.className="collapse-toggle hidden-default collapsed";newToggle.innerHTML="["+labelForToggleButton(true)+"] Show hidden undocumented items";function toggleClicked(){if(hasClass(this,"collapsed")){removeClass(this,"collapsed");onEachLazy(this.parentNode.getElementsByClassName("hidden"),function(x){if(hasClass(x,"content")===false){removeClass(x,"hidden");addClass(x,"x");}},true);this.innerHTML="["+labelForToggleButton(false)+"] Hide undocumented items";}else{addClass(this,"collapsed");onEachLazy(this.parentNode.getElementsByClassName("x"),function(x){if(hasClass(x,"content")===false){addClass(x,"hidden");removeClass(x,"x");}},true);this.innerHTML="["+labelForToggleButton(true)+"] Show hidden undocumented items";}}onEachLazy(document.getElementsByClassName("impl-items"),function(e){onEachLazy(e.getElementsByClassName("associatedconstant"),func);var hiddenElems=e.getElementsByClassName("hidden");var needToggle=false;var hlength=hiddenElems.length;for(var i=0;i0){inner[0].innerHTML="+";}}if(extraClass){addClass(wrapper,extraClass);}wrapper.appendChild(mainToggle);return wrapper;}var showItemDeclarations=getCurrentValue("rustdoc-item-declarations")==="false";function buildToggleWrapper(e){if(hasClass(e,"autohide")){var wrap=e.previousElementSibling;if(wrap&&hasClass(wrap,"toggle-wrapper")){var inner_toggle=wrap.childNodes[0];var extra=e.childNodes[0].tagName==="H3";e.style.display="none";addClass(wrap,"collapsed");onEachLazy(inner_toggle.getElementsByClassName("inner"),function(e){e.innerHTML=labelForToggleButton(true);});onEachLazy(inner_toggle.getElementsByClassName("toggle-label"),function(e){e.style.display="inline-block";if(extra===true){i_e.innerHTML=" Show "+e.childNodes[0].innerHTML;}});}}if(e.parentNode.id==="main"){var otherMessage="";var fontSize;var extraClass;if(hasClass(e,"type-decl")){fontSize="20px";otherMessage=" Show declaration";if(showItemDeclarations===false){extraClass="collapsed";}}else if(hasClass(e,"sub-variant")){otherMessage=" Show fields";}else if(hasClass(e,"non-exhaustive")){otherMessage=" This ";if(hasClass(e,"non-exhaustive-struct")){otherMessage+="struct";}else if(hasClass(e,"non-exhaustive-enum")){otherMessage+="enum";}else if(hasClass(e,"non-exhaustive-variant")){otherMessage+="enum variant";}else if(hasClass(e,"non-exhaustive-type")){otherMessage+="type";}otherMessage+=" is marked as non-exhaustive";}else if(hasClass(e.childNodes[0],"impl-items")){extraClass="marg-left";}e.parentNode.insertBefore(createToggle(otherMessage,fontSize,extraClass,hasClass(e,"type-decl")===false||showItemDeclarations===true),e);if(hasClass(e,"type-decl")===true&&showItemDeclarations===true){collapseDocs(e.previousSibling.childNodes[0],"toggle");}if(hasClass(e,"non-exhaustive")===true){collapseDocs(e.previousSibling.childNodes[0],"toggle");}}}onEachLazy(document.getElementsByClassName("docblock"),buildToggleWrapper);onEachLazy(document.getElementsByClassName("sub-variant"),buildToggleWrapper);function createToggleWrapper(tog){var span=document.createElement("span");span.className="toggle-label";span.style.display="none";span.innerHTML=" Expand attributes";tog.appendChild(span);var wrapper=document.createElement("div");wrapper.className="toggle-wrapper toggle-attributes";wrapper.appendChild(tog);return wrapper;}var itemAttributesFunc=function(){};if(getCurrentValue("rustdoc-item-attributes")!=="false"){itemAttributesFunc=function(x){collapseDocs(x.previousSibling.childNodes[0],"toggle");};}var attributesToggle=createToggleWrapper(createSimpleToggle(false));onEachLazy(main.getElementsByClassName("attributes"),function(i_e){var attr_tog=attributesToggle.cloneNode(true);if(hasClass(i_e,"top-attr")===true){addClass(attr_tog,"top-attr");}i_e.parentNode.insertBefore(attr_tog,i_e);itemAttributesFunc(i_e);});var lineNumbersFunc=function(){};if(getCurrentValue("rustdoc-line-numbers")==="true"){lineNumbersFunc=function(x){var count=x.textContent.split("\n").length;var elems=[];for(var i=0;i
✕"+"
"+content+"";document.getElementsByTagName("body")[0].appendChild(modal);document.getElementById("modal-close").onclick=hideModal;modal.onclick=hideModal;}function hideModal(){var modal=document.getElementById("important");if(modal){modal.parentNode.removeChild(modal);}}onEachLazy(document.getElementsByClassName("important-traits"),function(e){e.onclick=function(){showModal(e.lastElementChild.innerHTML);};});function printTab(nb){if(nb===0||nb===1||nb===2){currentTab=nb;}var nb_copy=nb;onEachLazy(document.getElementById("titles").childNodes,function(elem){if(nb_copy===0){addClass(elem,"selected");}else{removeClass(elem,"selected");}nb_copy-=1;});onEachLazy(document.getElementById("results").childNodes,function(elem){if(nb===0){elem.style.display="";}else{elem.style.display="none";}nb-=1;});}function putBackSearch(search_input){if(search_input.value!==""){addClass(main,"hidden");removeClass(document.getElementById("search"),"hidden");if(browserSupportsHistoryApi()){history.replaceState(search_input.value,"","?search="+encodeURIComponent(search_input.value));}}}if(search_input){search_input.onfocus=function(){putBackSearch(this);};}var params=getQueryStringParams();if(params&¶ms.search){addClass(main,"hidden");var search=document.getElementById("search");removeClass(search,"hidden");search.innerHTML="

Loading search results...

";}var sidebar_menu=document.getElementsByClassName("sidebar-menu")[0];if(sidebar_menu){sidebar_menu.onclick=function(){var sidebar=document.getElementsByClassName("sidebar")[0];if(hasClass(sidebar,"mobile")===true){hideSidebar();}else{showSidebar();}};}window.onresize=function(){hideSidebar();};autoCollapse(getPageId(),getCurrentValue("rustdoc-collapse")==="true");if(window.location.hash&&window.location.hash.length>0){expandSection(window.location.hash.replace(/^#/,""));}if(main){onEachLazy(main.getElementsByClassName("loading-content"),function(e){e.remove();});onEachLazy(main.childNodes,function(e){if(e.tagName==="H2"||e.tagName==="H3"){var nextTagName=e.nextElementSibling.tagName;if(nextTagName=="H2"||nextTagName=="H3"){e.nextElementSibling.style.display="flex";}else{e.nextElementSibling.style.display="block";}}});}function addSearchOptions(crates){var elem=document.getElementById('crate-search');if(!elem){return;}var crates_text=[];if(Object.keys(crates).length>1){for(var crate in crates){if(crates.hasOwnProperty(crate)){crates_text.push(crate);}}}crates_text.sort(function(a,b){var lower_a=a.toLowerCase();var lower_b=b.toLowerCase();if(lower_alower_b){return 1;}return 0;});for(var i=0;ih2+div,#main>h2+h3,#main>h3+div{display:block;}.loading-content{display:none;} \ No newline at end of file diff --git a/docs/api/duckscript/rust-logo.png b/docs/api/duckscript/rust-logo.png new file mode 100644 index 0000000..46f0999 Binary files /dev/null and b/docs/api/duckscript/rust-logo.png differ diff --git a/docs/api/duckscript/rustdoc.css b/docs/api/duckscript/rustdoc.css new file mode 100644 index 0000000..c0f75a4 --- /dev/null +++ b/docs/api/duckscript/rustdoc.css @@ -0,0 +1 @@ + @font-face {font-family:'Fira Sans';font-style:normal;font-weight:400;src:local('Fira Sans'),url("FiraSans-Regular.woff") format('woff');}@font-face {font-family:'Fira Sans';font-style:normal;font-weight:500;src:local('Fira Sans Medium'),url("FiraSans-Medium.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:normal;font-weight:400;src:local('Source Serif Pro'),url("SourceSerifPro-Regular.ttf.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:italic;font-weight:400;src:local('Source Serif Pro Italic'),url("SourceSerifPro-It.ttf.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:normal;font-weight:700;src:local('Source Serif Pro Bold'),url("SourceSerifPro-Bold.ttf.woff") format('woff');}@font-face {font-family:'Source Code Pro';font-style:normal;font-weight:400;src:url("SourceCodePro-Regular.woff") format('woff');}@font-face {font-family:'Source Code Pro';font-style:normal;font-weight:600;src:url("SourceCodePro-Semibold.woff") format('woff');}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}body{font:16px/1.4 "Source Serif Pro",serif;margin:0;position:relative;padding:10px 15px 20px 15px;-webkit-font-feature-settings:"kern","liga";-moz-font-feature-settings:"kern","liga";font-feature-settings:"kern","liga";}h1{font-size:1.5em;}h2{font-size:1.4em;}h3{font-size:1.3em;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.important),h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant){font-weight:500;margin:20px 0 15px 0;padding-bottom:6px;}h1.fqn{border-bottom:1px dashed;margin-top:0;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant){border-bottom:1px solid;}h3.impl,h3.method,h4.method,h3.type,h4.type,h4.associatedconstant{flex-basis:100%;font-weight:600;margin-top:16px;margin-bottom:10px;position:relative;}h3.impl,h3.method,h3.type{padding-left:15px;}h1,h2,h3,h4,.sidebar,a.source,.search-input,.content table :not(code)>a,.collapse-toggle,div.item-list .out-of-band,#source-sidebar,#sidebar-toggle{font-family:"Fira Sans",sans-serif;}ol,ul{padding-left:25px;}ul ul,ol ul,ul ol,ol ol{margin-bottom:.6em;}p{margin:0 0 .6em 0;}summary{outline:none;}code,pre{font-family:"Source Code Pro",monospace;}.docblock code,.docblock-short code{border-radius:3px;padding:0 0.1em;}.docblock pre code,.docblock-short pre code,.docblock code.spotlight{padding:0;}.docblock code.spotlight :last-child{padding-bottom:0.6em;}pre{padding:14px;}.source .content pre{padding:20px;}img{max-width:100%;}li{position:relative;}.source .content{margin-top:50px;max-width:none;overflow:visible;margin-left:0px;min-width:70em;}nav.sub{font-size:16px;text-transform:uppercase;}.sidebar{width:200px;position:fixed;left:0;top:0;height:100vh;overflow:auto;}.sidebar .block>ul>li{margin-right:-10px;}.content,nav{max-width:960px;}.js-only,.hidden{display:none !important;}.logo-container{height:100px;width:100px;position:relative;margin:20px auto;display:block;margin-top:10px;}.logo-container>img{max-width:100px;max-height:100px;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:block;}.sidebar .location{border:1px solid;font-size:17px;margin:30px 10px 20px 10px;text-align:center;word-wrap:break-word;}.sidebar .version{font-size:15px;text-align:center;border-bottom:1px solid;overflow-wrap:break-word;word-wrap:break-word;word-break:break-word;}.location:empty{border:none;}.location a:first-child{font-weight:500;}.block{padding:0;margin-bottom:14px;}.block h2,.block h3{margin-top:0;margin-bottom:8px;text-align:center;}.block ul,.block li{margin:0 10px;padding:0;list-style:none;}.block a{display:block;text-overflow:ellipsis;overflow:hidden;line-height:15px;padding:7px 5px;font-size:14px;font-weight:300;transition:border 500ms ease-out;}.sidebar-title{border-top:1px solid;border-bottom:1px solid;text-align:center;font-size:17px;margin-bottom:5px;}.sidebar-links{margin-bottom:15px;}.sidebar-links>a{padding-left:10px;width:100%;}.sidebar-menu{display:none;}.content{padding:15px 0;}.source .content pre.rust{white-space:pre;overflow:auto;padding-left:0;}.rustdoc:not(.source) .example-wrap{display:inline-flex;margin-bottom:10px;}.example-wrap{width:100%;}.example-wrap>pre.line-number{overflow:initial;border:1px solid;border-top-left-radius:5px;border-bottom-left-radius:5px;padding:13px 8px;text-align:right;}.rustdoc:not(.source) .example-wrap>pre.rust{width:100%;overflow-x:auto;}.rustdoc:not(.source) .example-wrap>pre{margin:0;}#search{margin-left:230px;position:relative;}#results{position:absolute;right:0;left:0;overflow:auto;}#results>table{width:100%;table-layout:fixed;}.content pre.line-numbers{float:left;border:none;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}.line-numbers span{cursor:pointer;}.docblock-short p{display:inline;}.docblock-short.nowrap{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}.docblock-short p{overflow:hidden;text-overflow:ellipsis;margin:0;}.docblock-short code{white-space:pre-wrap;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom:1px solid;}#main>.docblock h1{font-size:1.3em;}#main>.docblock h2{font-size:1.15em;}#main>.docblock h3,#main>.docblock h4,#main>.docblock h5{font-size:1em;}#main>h2+div,#main>h2+h3,#main>h3+div{display:none;flex-wrap:wrap;}.docblock h1{font-size:1em;}.docblock h2{font-size:0.95em;}.docblock h3,.docblock h4,.docblock h5{font-size:0.9em;}.docblock{margin-left:24px;position:relative;}.content .out-of-band{float:right;font-size:23px;margin:0px;padding:0px;font-weight:normal;}h3.impl>.out-of-band{font-size:21px;}h4.method>.out-of-band{font-size:19px;}h4>code,h3>code,.invisible>code{max-width:calc(100% - 41px);display:block;}.invisible{width:100%;display:inline-block;}.content .in-band{margin:0px;padding:0px;}.in-band>code{display:inline-block;}#main{position:relative;}#main>.since{top:inherit;font-family:"Fira Sans",sans-serif;}.content table:not(.table-display){border-spacing:0 5px;}.content td{vertical-align:top;}.content td:first-child{padding-right:20px;}.content td p:first-child{margin-top:0;}.content td h1,.content td h2{margin-left:0;font-size:1.1em;}.content tr:first-child td{border-top:0;}.docblock table{margin:.5em 0;width:calc(100% - 2px);border:1px dashed;}.docblock table td{padding:.5em;border:1px dashed;}.docblock table th{padding:.5em;text-align:left;border:1px solid;}.fields+table{margin-bottom:1em;}.content .item-list{list-style-type:none;padding:0;}.content .multi-column{-moz-column-count:5;-moz-column-gap:2.5em;-webkit-column-count:5;-webkit-column-gap:2.5em;column-count:5;column-gap:2.5em;}.content .multi-column li{width:100%;display:inline-block;}.content .method{font-size:1em;position:relative;}.content .method .where,.content .fn .where,.content .where.fmt-newline{display:block;font-size:0.8em;}.content .methods>div:not(.important-traits){margin-left:40px;margin-bottom:15px;}.content .docblock>.impl-items{margin-left:20px;margin-top:-34px;}.content .docblock>.impl-items>h4{border-bottom:0;}.content .docblock>.impl-items .table-display{margin:0;}.content .docblock>.impl-items table td{padding:0;}.toggle-wrapper.marg-left>.collapse-toggle{left:-24px;}.content .docblock>.impl-items .table-display,.impl-items table td{border:none;}.content .stability code{font-size:90%;}.content .stability{position:relative;margin-left:33px;margin-top:-13px;}.sub-variant>div>.stability{margin-top:initial;}.content .stability::before{content:'˪';font-size:30px;position:absolute;top:-9px;left:-13px;}.content .impl-items .method,.content .impl-items>.type,.impl-items>.associatedconstant{margin-left:20px;}.content .impl-items .docblock,.content .impl-items .stability{margin-bottom:.6em;}.content .impl-items>.stability{margin-left:40px;}.methods>.stability,.content .impl-items>.stability{margin-top:-8px;}.impl-items{flex-basis:100%;}#main>.stability{margin-top:0;}nav{border-bottom:1px solid;padding-bottom:10px;margin-bottom:10px;}nav.main{padding:20px 0;text-align:center;}nav.main .current{border-top:1px solid;border-bottom:1px solid;}nav.main .separator{border:1px solid;display:inline-block;height:23px;margin:0 20px;}nav.sum{text-align:right;}nav.sub form{display:inline;}nav.sub,.content{margin-left:230px;}a{text-decoration:none;background:transparent;}.small-section-header:hover>.anchor{display:initial;}.in-band:hover>.anchor{display:inline-block;position:absolute;}.anchor{display:none;position:absolute;left:-7px;}.anchor.field{left:-5px;}.small-section-header>.anchor{left:-28px;padding-right:10px;}.anchor:before{content:'\2002\00a7\2002';}.docblock a:not(.srclink):not(.test-arrow):hover,.docblock-short a:not(.srclink):not(.test-arrow):hover,.stability a{text-decoration:underline;}.invisible>.srclink,h4>code+.srclink{position:absolute;top:0;right:0;font-size:17px;font-weight:normal;}.block a.current.crate{font-weight:500;}.search-container{position:relative;}.search-container>div{display:inline-flex;width:calc(100% - 34px);}#crate-search{margin-top:5px;padding:6px;padding-right:19px;flex:none;border:0;border-right:0;border-radius:4px 0 0 4px;outline:none;cursor:pointer;border-right:1px solid;-moz-appearance:none;-webkit-appearance:none;text-indent:0.01px;text-overflow:"";background-repeat:no-repeat;background-color:transparent;background-size:20px;background-position:calc(100% - 1px) 56%;}.search-container>.top-button{position:absolute;right:0;top:10px;}.search-input{-moz-box-sizing:border-box !important;box-sizing:border-box !important;outline:none;border:none;border-radius:1px;margin-top:5px;padding:10px 16px;font-size:17px;transition:border-color 300ms ease;transition:border-radius 300ms ease-in-out;transition:box-shadow 300ms ease-in-out;width:100%;}#crate-search+.search-input{border-radius:0 1px 1px 0;width:calc(100% - 32px);}.search-input:focus{border-radius:2px;border:0;outline:0;}.search-results .desc{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;display:block;}.search-results a{display:block;}.content .search-results td:first-child{padding-right:0;width:50%;}.content .search-results td:first-child a{padding-right:10px;}.content .search-results td:first-child a:after{clear:both;content:"";display:block;}.content .search-results td:first-child a span{float:left;}tr.result span.primitive::after{content:' (primitive type)';font-style:italic;}tr.result span.keyword::after{content:' (keyword)';font-style:italic;}body.blur>:not(#help){filter:blur(8px);-webkit-filter:blur(8px);opacity:.7;}#help{width:100%;height:100vh;position:fixed;top:0;left:0;display:flex;justify-content:center;align-items:center;}#help>div{flex:0 0 auto;box-shadow:0 0 6px rgba(0,0,0,.2);width:550px;height:auto;border:1px solid;}#help dt{float:left;clear:left;display:block;}#help dd{margin:5px 35px;}#help .infos{padding-left:0;}#help h1,#help h2{margin-top:0;}#help>div div{width:50%;float:left;padding:20px;padding-left:17px;}.stab{display:table;border-width:1px;border-style:solid;padding:3px;margin-bottom:5px;font-size:90%;}.stab p{display:inline;}.stab summary{display:list-item;}.stab .emoji{font-size:1.5em;}.module-item .stab{border-radius:3px;display:inline-block;font-size:80%;line-height:1.2;margin-bottom:0;margin-right:.3em;padding:2px;vertical-align:text-bottom;}.module-item.unstable{opacity:0.65;}.since{font-weight:normal;font-size:initial;position:absolute;right:0;top:0;}.impl-items .since,.impl .since{flex-grow:0;padding-left:12px;padding-right:2px;position:initial;}.impl-items .srclink,.impl .srclink{flex-grow:0;font-size:17px;font-weight:normal;}.impl-items code,.impl code{flex-grow:1;}.impl-items h4,h4.impl,h3.impl{display:flex;flex-basis:100%;font-size:16px;margin-bottom:12px;justify-content:space-between;}.variants_table{width:100%;}.variants_table tbody tr td:first-child{width:1%;}td.summary-column{width:100%;}.summary{padding-right:0px;}pre.rust .question-mark{font-weight:bold;}a.test-arrow{display:inline-block;position:absolute;padding:5px 10px 5px 10px;border-radius:5px;font-size:130%;top:5px;right:5px;}a.test-arrow:hover{text-decoration:none;}.section-header:hover a:before{position:absolute;left:-25px;padding-right:10px;content:'\2002\00a7\2002';}.section-header:hover a{text-decoration:none;}.section-header a{color:inherit;}.collapse-toggle{font-weight:300;position:absolute;left:-23px;top:0;}h3>.collapse-toggle,h4>.collapse-toggle{font-size:0.8em;top:5px;}.toggle-wrapper>.collapse-toggle{left:-24px;margin-top:0px;}.toggle-wrapper{position:relative;margin-top:0;}.toggle-wrapper.collapsed{height:25px;transition:height .2s;margin-bottom:.6em;}.collapse-toggle>.inner{display:inline-block;width:1.2ch;text-align:center;}.collapse-toggle.hidden-default{position:relative;margin-left:20px;}.since+.srclink{display:table-cell;padding-left:10px;}.item-spacer{width:100%;height:12px;}.out-of-band>span.since{position:initial;font-size:20px;margin-right:5px;}.toggle-wrapper>.collapse-toggle{left:0;}.variant+.toggle-wrapper+.docblock>p{margin-top:5px;}.sub-variant,.sub-variant>h3{margin-top:1px !important;}#main>.sub-variant>h3{font-size:15px;margin-left:25px;margin-bottom:5px;}.sub-variant>div{margin-left:20px;margin-bottom:10px;}.sub-variant>div>span{display:block;position:relative;}.toggle-label{display:inline-block;margin-left:4px;margin-top:3px;}.enum>.toggle-wrapper+.docblock,.struct>.toggle-wrapper+.docblock{margin-left:30px;margin-bottom:20px;margin-top:5px;}.docblock>.section-header:first-child{margin-left:15px;margin-top:0;}.docblock>.section-header:first-child:hover>a:before{left:-10px;}.enum>.collapsed,.struct>.collapsed{margin-bottom:25px;}#main>.variant,#main>.structfield{display:block;}.attributes{display:block;margin-top:0px !important;margin-right:0px;margin-bottom:0px !important;margin-left:30px;}.toggle-attributes.collapsed{margin-bottom:0;}.impl-items>.toggle-attributes{margin-left:20px;}.impl-items .attributes{font-weight:500;}:target>code{opacity:1;}.information{position:absolute;left:-20px;margin-top:7px;z-index:1;}.tooltip{position:relative;display:inline-block;cursor:pointer;}.tooltip .tooltiptext{width:120px;display:none;text-align:center;padding:5px 3px;border-radius:6px;margin-left:5px;top:-5px;left:105%;z-index:10;}.tooltip:hover .tooltiptext{display:inline;}.tooltip .tooltiptext::after{content:" ";position:absolute;top:50%;left:11px;margin-top:-5px;border-width:5px;border-style:solid;}.important-traits .tooltip .tooltiptext{border:1px solid;}pre.rust{position:relative;tab-width:4;-moz-tab-width:4;}.search-failed{text-align:center;margin-top:20px;}.search-failed>ul{text-align:left;max-width:570px;margin-left:auto;margin-right:auto;}#titles{height:35px;}#titles>div{float:left;width:33.3%;text-align:center;font-size:18px;cursor:pointer;border-top:2px solid;}#titles>div:not(:last-child){margin-right:1px;width:calc(33.3% - 1px);}#titles>div>div.count{display:inline-block;font-size:16px;}.important-traits{cursor:pointer;z-index:2;}h4>.important-traits{position:absolute;left:-44px;top:2px;}#all-types{text-align:center;border:1px solid;margin:0 10px;margin-bottom:10px;display:block;border-radius:7px;}#all-types>p{margin:5px 0;}#sidebar-toggle{position:fixed;top:30px;left:300px;z-index:10;padding:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;cursor:pointer;font-weight:bold;transition:left .5s;font-size:1.2em;border:1px solid;border-left:0;}#source-sidebar{position:fixed;top:0;bottom:0;left:0;width:300px;z-index:1;overflow:auto;transition:left .5s;border-right:1px solid;}#source-sidebar>.title{font-size:1.5em;text-align:center;border-bottom:1px solid;margin-bottom:6px;}.theme-picker{position:absolute;left:211px;top:19px;}.theme-picker button{outline:none;}#settings-menu{position:absolute;right:0;top:10px;outline:none;}#theme-picker,#settings-menu{padding:4px;width:27px;height:29px;border:1px solid;border-radius:3px;cursor:pointer;}#theme-choices{display:none;position:absolute;left:0;top:28px;border:1px solid;border-radius:3px;z-index:1;cursor:pointer;}#theme-choices>button{border:none;width:100%;padding:4px;text-align:center;background:rgba(0,0,0,0);}#theme-choices>button:not(:first-child){border-top:1px solid;}@media (max-width:700px){body{padding-top:0px;}.rustdoc>.sidebar{height:45px;min-height:40px;margin:0;margin-left:-15px;padding:0 15px;position:static;z-index:11;}.sidebar>.location{float:right;margin:0px;margin-top:2px;padding:3px 10px 1px 10px;min-height:39px;background:inherit;text-align:left;font-size:24px;}.sidebar .location:empty{padding:0;}.sidebar .logo-container{width:35px;height:35px;margin-top:5px;margin-bottom:5px;float:left;margin-left:50px;}.sidebar .logo-container>img{max-width:35px;max-height:35px;}.sidebar-menu{position:fixed;z-index:10;font-size:2rem;cursor:pointer;width:45px;left:0;text-align:center;display:block;border-bottom:1px solid;border-right:1px solid;height:45px;}.rustdoc.source>.sidebar>.sidebar-menu{display:none;}.sidebar-elems{position:fixed;z-index:1;left:0;top:45px;bottom:0;overflow-y:auto;border-right:1px solid;display:none;}.sidebar>.block.version{border-bottom:none;margin-top:12px;}nav.sub{width:calc(100% - 32px);float:right;}.content{margin-left:0px;}#main{margin-top:45px;padding:0;}.content .in-band{width:100%;}.content h4>.out-of-band{position:inherit;}.toggle-wrapper>.collapse-toggle{left:0px;}.toggle-wrapper{height:1.5em;}#search{margin-left:0;}.content .impl-items .method,.content .impl-items>.type,.impl-items>.associatedconstant{display:flex;}.anchor{display:none !important;}h1.fqn{overflow:initial;}.theme-picker{left:10px;top:54px;z-index:1;}h4>.important-traits{position:absolute;left:-22px;top:24px;}#titles>div>div.count{float:left;width:100%;}#titles{height:50px;}.sidebar.mobile{position:fixed;width:100%;margin-left:0;background-color:rgba(0,0,0,0);height:100%;}.sidebar{width:calc(100% + 30px);}.show-it{display:block;width:246px;}.show-it>.block.items{margin:8px 0;}.show-it>.block.items>ul{margin:0;}.show-it>.block.items>ul>li{text-align:center;margin:2px 0;}.show-it>.block.items>ul>li>a{font-size:21px;}#sidebar-filler{position:fixed;left:45px;width:calc(100% - 45px);top:0;height:45px;z-index:-1;border-bottom:1px solid;}.collapse-toggle{left:-20px;}.impl>.collapse-toggle{left:-10px;}#all-types{margin:10px;}#sidebar-toggle{top:100px;width:30px;font-size:1.5rem;text-align:center;padding:0;}#source-sidebar{z-index:11;}#main>.line-numbers{margin-top:0;}}@media print{nav.sub,.content .out-of-band,.collapse-toggle{display:none;}}@media (max-width:416px){#titles{height:73px;}#titles>div{height:73px;}}.modal{position:fixed;width:100vw;height:100vh;z-index:10000;top:0;left:0;}.modal-content{display:block;max-width:60%;min-width:200px;padding:8px;top:40%;position:absolute;left:50%;transform:translate(-50%,-40%);border:1px solid;border-radius:4px;border-top-right-radius:0;}.modal-content>.docblock{margin:0;}h3.important{margin:0;margin-bottom:13px;font-size:19px;}.modal-content>.docblock>code.content{margin:0;padding:0;font-size:20px;}.modal-content>.close{position:absolute;font-weight:900;right:-25px;top:-1px;font-size:18px;width:25px;padding-right:2px;border-top-right-radius:5px;border-bottom-right-radius:5px;text-align:center;border:1px solid;border-right:0;cursor:pointer;}.modal-content>.whiter{height:25px;position:absolute;width:3px;right:-2px;top:0px;}#main>div.important-traits{position:absolute;left:-24px;margin-top:16px;}.content>.methods>.method>div.important-traits{position:absolute;font-weight:400;left:-42px;margin-top:2px;}kbd{display:inline-block;padding:3px 5px;font:15px monospace;line-height:10px;vertical-align:middle;border:solid 1px;border-radius:3px;box-shadow:inset 0 -1px 0;cursor:default;}.hidden-by-impl-hider,.hidden-by-usual-hider{display:none !important;}#implementations-list>h3>span.in-band{width:100%;}.table-display{width:100%;border:0;border-collapse:collapse;border-spacing:0;font-size:16px;}.table-display tr td:first-child{padding-right:0;}.table-display tr td:last-child{float:right;}.table-display .out-of-band{position:relative;font-size:19px;display:block;}#implementors-list>.impl-items .table-display .out-of-band{font-size:17px;}.table-display td:hover .anchor{display:block;top:2px;left:-5px;}#main>ul{padding-left:10px;}#main>ul>li{list-style:none;}.non-exhaustive{margin-bottom:1em;}div.children{padding-left:27px;display:none;}div.name{cursor:pointer;position:relative;margin-left:16px;}div.files>a{display:block;padding:0 3px;}div.files>a:hover,div.name:hover{background-color:#a14b4b;}div.name.expand+.children{display:block;}div.name::before{content:"\25B6";padding-left:4px;font-size:0.7em;position:absolute;left:-16px;top:4px;}div.name.expand::before{transform:rotate(90deg);left:-15px;top:2px;}.type-decl>pre>.toggle-wrapper.toggle-attributes.top-attr{margin-left:0 !important;}.type-decl>pre>.docblock.attributes.top-attr{margin-left:1.8em !important;}.type-decl>pre>.toggle-attributes{margin-left:2.2em;}.type-decl>pre>.docblock.attributes{margin-left:4em;} \ No newline at end of file diff --git a/docs/api/duckscript/search-index.js b/docs/api/duckscript/search-index.js new file mode 100644 index 0000000..641d1de --- /dev/null +++ b/docs/api/duckscript/search-index.js @@ -0,0 +1,5 @@ +var N=null,E="",T="t",U="u",searchIndex={}; +var R=["duckscript","parser","scripterror","instruction","result","runner","context","hashmap","command","commands","string","commandresult","duckscript::types","Holds the error information","Error Info Type","The command name","arguments","The command arguments","Preprocess instruction","Runtime script instruction","Creates and returns a new instance.","signed number","unsigned number","runtime","duckscript::types::command","try_from","try_into","borrow_mut","to_owned","clone_into","type_id","duckscript::types::error","borrow","typeid","duckscript::types::instruction","duckscript::types::runtime","preprocessinstruction","scriptinstruction","instructionmetainfo","formatter","Commands","GoToValue","CommandResult","ScriptError","ErrorInfo","PreProcessInstruction","ScriptInstruction","InstructionMetaInfo","Instruction","InstructionType","Runtime","StateValue"]; + +searchIndex["duckscript"]={"doc":R[0],"i":[[0,R[1],R[0],R[1],N,N],[5,"parse_file","duckscript::parser","parses the file and returns a vector of instructions",N,[[["str"]],[["vec",[R[3]]],[R[4],["vec",R[2]]],[R[2]]]]],[5,"parse_text",E,"parses the provided script text and returns a vector of…",N,[[["str"]],[["vec",[R[3]]],[R[4],["vec",R[2]]],[R[2]]]]],[0,R[5],R[0],R[5],N,N],[5,"run_script","duckscript::runner","Executes the provided script with the given context",N,[[[R[6]],["str"]],[[R[4],[R[6],R[2]]],[R[6]],[R[2]]]]],[5,"run_script_file",E,"Executes the provided script file with the given context",N,[[[R[6]],["str"]],[[R[4],[R[6],R[2]]],[R[6]],[R[2]]]]],[5,"run_instruction",E,"Enables to evaluate a single instruction and return its…",N,[[[R[7]],["vec"],[R[9]],[R[7]],[R[3]],["usize"]]]],[0,"types",R[0],"types",N,N],[0,R[8],R[12],R[8],N,N],[3,R[40],R[24],"Holds and enables access to the runtime commands…",N,N],[12,R[9],E,"mapping between command names to implementations",0,N],[12,"aliases",E,"mapping between aliases to command names",0,N],[4,R[41],E,"GoTo type value",N,N],[13,"Label",E,"label target",1,N],[13,"Line",E,"Line number",1,N],[4,R[42],E,"Command execution result",N,N],[13,"Continue",E,"Holds the command output and tells the runner to continue…",2,N],[13,"GoTo",E,"Holds the command output and tells the runner to jump to…",2,N],[13,"Error",E,"Holds the error message and the meta info of the…",2,N],[13,"Crash",E,"Holds the critical error message and the meta info of the…",2,N],[13,"Exit",E,"Holds the command output and tells the runner to stop the…",2,N],[8,"Command",E,"Defines the command capabilities",N,N],[10,"name",E,"The full command name which can be used to invoke this…",3,[[["self"]],[R[10]]]],[11,"aliases",E,"A list of aliases that can also be used to invoke this…",3,[[["self"]],[["vec",[R[10]]],[R[10]]]]],[11,"help",E,"Command documentation.",3,[[["self"]],[R[10]]]],[11,"requires_context",E,"If true the run with the context will be invoked.",3,[[["self"]],["bool"]]],[11,"run",E,"Runs the given instruction",3,[[["vec",[R[10]]],[R[10]],["self"]],[R[11]]]],[11,"run_with_context",E,"Run the instruction with access to the runtime context.",3,[[[R[9]],["vec",[R[10]]],[R[7]],[R[10]],["option",[R[10]]],[R[7]],["vec"],["self"],["usize"]],[R[11]]]],[11,"new",E,R[20],0,[[],[R[9]]]],[11,"return_after_usage",E,"Returns the command after it was being used. No…",0,[[[R[8]],["self"],["box",[R[8]]]]]],[11,"set",E,"Adds a new command definition. It will fail in case…",0,[[[R[8]],["self"],["box",[R[8]]]],[[R[4],[R[2]]],[R[2]]]]],[11,"get",E,"Return the command based on the given command name/alias",0,[[["str"],["self"]],[["option",["box"]],["box"]]]],[11,"exists",E,"Return true if the command based on the given command…",0,[[["str"],["self"]],["bool"]]],[11,"get_for_use",E,"Return the command based on the given command name/alias.…",0,[[["self"],["str"]],[["option",["box"]],["box",[R[8]]]]]],[11,"get_all_command_names",E,"Returns all the command names currently registered",0,[[["self"]],[["vec",[R[10]]],[R[10]]]]],[11,"remove",E,"Removes the requested command.",0,[[["self"],["str"]]]],[0,"error",R[12],"error",N,N],[3,R[43],R[31],"Script error struct",N,N],[12,"info",E,R[13],4,N],[4,R[44],E,R[13],N,N],[13,"ErrorReadingFile",E,R[14],5,N],[13,"Initialization",E,R[14],5,N],[13,R[50],E,R[14],5,N],[13,"PreProcessNoCommandFound",E,R[14],5,N],[13,"ControlWithoutValidValue",E,R[14],5,N],[13,"InvalidControlLocation",E,R[14],5,N],[13,"MissingEndQuotes",E,R[14],5,N],[13,"MissingOutputVariableName",E,R[14],5,N],[13,"InvalidEqualsLocation",E,R[14],5,N],[13,"InvalidQuotesLocation",E,R[14],5,N],[13,"EmptyLabel",E,R[14],5,N],[13,"UnknownPreProcessorCommand",E,R[14],5,N],[0,R[3],R[12],R[3],N,N],[3,R[45],R[34],R[18],N,N],[12,R[8],E,R[15],6,N],[12,R[16],E,R[17],6,N],[3,R[46],E,R[19],N,N],[12,"label",E,"The label tag",7,N],[12,"output",E,"The command output variable name",7,N],[12,R[8],E,R[15],7,N],[12,R[16],E,R[17],7,N],[3,R[47],E,"Meta information for all instruction types",N,N],[12,"line",E,"The line number",8,N],[12,"source",E,"The source file/url/...",8,N],[3,R[48],E,"Instruction data",N,N],[12,"meta_info",E,"Meta info",9,N],[12,"instruction_type",E,"The instruction",9,N],[4,R[49],E,"Instruction Type - script, preprocess",N,N],[13,"Empty",E,"Empty instruction",10,N],[13,"PreProcess",E,R[18],10,N],[13,"Script",E,R[19],10,N],[11,"new",E,R[20],6,[[],[R[36]]]],[11,"new",E,R[20],7,[[],[R[37]]]],[11,"new",E,R[20],8,[[],[R[38]]]],[0,R[23],R[12],R[23],N,N],[3,"Context",R[35],"The context structure",N,N],[12,"variables",E,"The runtime variables",11,N],[12,"state",E,"The runtime state",11,N],[12,R[9],E,"The command implementations",11,N],[3,R[50],E,"The runtime structure",N,N],[12,"instructions",E,"The script instructions",12,N],[12,"label_to_line",E,"Label to line number mapping",12,N],[12,R[6],E,"The runtime context",12,N],[4,R[51],E,"enum defining what values can be stored in the state map",N,N],[13,"Boolean",E,"boolean value",13,N],[13,"Number",E,R[21],13,N],[13,"UnsignedNumber",E,R[22],13,N],[13,"Number32Bit",E,R[21],13,N],[13,"UnsignedNumber32Bit",E,R[22],13,N],[13,"Number64Bit",E,R[21],13,N],[13,"UnsignedNumber64Bit",E,R[22],13,N],[13,"String",E,"textual value",13,N],[13,"List",E,"list",13,N],[13,"SubState",E,"sub state value",13,N],[11,"new",E,R[20],11,[[],[R[6]]]],[11,"new",E,R[20],12,[[[R[6]]],[R[23]]]],[11,"from",R[24],E,0,[[[T]],[T]]],[11,"into",E,E,0,[[],[U]]],[11,R[25],E,E,0,[[[U]],[R[4]]]],[11,R[26],E,E,0,[[],[R[4]]]],[11,R[27],E,E,0,[[["self"]],[T]]],[11,R[32],E,E,0,[[["self"]],[T]]],[11,R[30],E,E,0,[[["self"]],[R[33]]]],[11,"from",E,E,1,[[[T]],[T]]],[11,"into",E,E,1,[[],[U]]],[11,R[28],E,E,1,[[["self"]],[T]]],[11,R[29],E,E,1,[[[T],["self"]]]],[11,R[25],E,E,1,[[[U]],[R[4]]]],[11,R[26],E,E,1,[[],[R[4]]]],[11,R[27],E,E,1,[[["self"]],[T]]],[11,R[32],E,E,1,[[["self"]],[T]]],[11,R[30],E,E,1,[[["self"]],[R[33]]]],[11,"from",E,E,2,[[[T]],[T]]],[11,"into",E,E,2,[[],[U]]],[11,R[28],E,E,2,[[["self"]],[T]]],[11,R[29],E,E,2,[[[T],["self"]]]],[11,R[25],E,E,2,[[[U]],[R[4]]]],[11,R[26],E,E,2,[[],[R[4]]]],[11,R[27],E,E,2,[[["self"]],[T]]],[11,R[32],E,E,2,[[["self"]],[T]]],[11,R[30],E,E,2,[[["self"]],[R[33]]]],[11,"from",R[31],E,4,[[[T]],[T]]],[11,"into",E,E,4,[[],[U]]],[11,"to_string",E,E,4,[[["self"]],[R[10]]]],[11,R[25],E,E,4,[[[U]],[R[4]]]],[11,R[26],E,E,4,[[],[R[4]]]],[11,R[27],E,E,4,[[["self"]],[T]]],[11,R[32],E,E,4,[[["self"]],[T]]],[11,R[30],E,E,4,[[["self"]],[R[33]]]],[11,"from",E,E,5,[[[T]],[T]]],[11,"into",E,E,5,[[],[U]]],[11,R[25],E,E,5,[[[U]],[R[4]]]],[11,R[26],E,E,5,[[],[R[4]]]],[11,R[27],E,E,5,[[["self"]],[T]]],[11,R[32],E,E,5,[[["self"]],[T]]],[11,R[30],E,E,5,[[["self"]],[R[33]]]],[11,"from",R[34],E,6,[[[T]],[T]]],[11,"into",E,E,6,[[],[U]]],[11,R[28],E,E,6,[[["self"]],[T]]],[11,R[29],E,E,6,[[[T],["self"]]]],[11,R[25],E,E,6,[[[U]],[R[4]]]],[11,R[26],E,E,6,[[],[R[4]]]],[11,R[27],E,E,6,[[["self"]],[T]]],[11,R[32],E,E,6,[[["self"]],[T]]],[11,R[30],E,E,6,[[["self"]],[R[33]]]],[11,"from",E,E,7,[[[T]],[T]]],[11,"into",E,E,7,[[],[U]]],[11,R[28],E,E,7,[[["self"]],[T]]],[11,R[29],E,E,7,[[[T],["self"]]]],[11,R[25],E,E,7,[[[U]],[R[4]]]],[11,R[26],E,E,7,[[],[R[4]]]],[11,R[27],E,E,7,[[["self"]],[T]]],[11,R[32],E,E,7,[[["self"]],[T]]],[11,R[30],E,E,7,[[["self"]],[R[33]]]],[11,"from",E,E,8,[[[T]],[T]]],[11,"into",E,E,8,[[],[U]]],[11,R[28],E,E,8,[[["self"]],[T]]],[11,R[29],E,E,8,[[[T],["self"]]]],[11,R[25],E,E,8,[[[U]],[R[4]]]],[11,R[26],E,E,8,[[],[R[4]]]],[11,R[27],E,E,8,[[["self"]],[T]]],[11,R[32],E,E,8,[[["self"]],[T]]],[11,R[30],E,E,8,[[["self"]],[R[33]]]],[11,"from",E,E,9,[[[T]],[T]]],[11,"into",E,E,9,[[],[U]]],[11,R[28],E,E,9,[[["self"]],[T]]],[11,R[29],E,E,9,[[[T],["self"]]]],[11,R[25],E,E,9,[[[U]],[R[4]]]],[11,R[26],E,E,9,[[],[R[4]]]],[11,R[27],E,E,9,[[["self"]],[T]]],[11,R[32],E,E,9,[[["self"]],[T]]],[11,R[30],E,E,9,[[["self"]],[R[33]]]],[11,"from",E,E,10,[[[T]],[T]]],[11,"into",E,E,10,[[],[U]]],[11,R[28],E,E,10,[[["self"]],[T]]],[11,R[29],E,E,10,[[[T],["self"]]]],[11,R[25],E,E,10,[[[U]],[R[4]]]],[11,R[26],E,E,10,[[],[R[4]]]],[11,R[27],E,E,10,[[["self"]],[T]]],[11,R[32],E,E,10,[[["self"]],[T]]],[11,R[30],E,E,10,[[["self"]],[R[33]]]],[11,"from",R[35],E,11,[[[T]],[T]]],[11,"into",E,E,11,[[],[U]]],[11,R[25],E,E,11,[[[U]],[R[4]]]],[11,R[26],E,E,11,[[],[R[4]]]],[11,R[27],E,E,11,[[["self"]],[T]]],[11,R[32],E,E,11,[[["self"]],[T]]],[11,R[30],E,E,11,[[["self"]],[R[33]]]],[11,"from",E,E,12,[[[T]],[T]]],[11,"into",E,E,12,[[],[U]]],[11,R[25],E,E,12,[[[U]],[R[4]]]],[11,R[26],E,E,12,[[],[R[4]]]],[11,R[27],E,E,12,[[["self"]],[T]]],[11,R[32],E,E,12,[[["self"]],[T]]],[11,R[30],E,E,12,[[["self"]],[R[33]]]],[11,"from",E,E,13,[[[T]],[T]]],[11,"into",E,E,13,[[],[U]]],[11,R[28],E,E,13,[[["self"]],[T]]],[11,R[29],E,E,13,[[[T],["self"]]]],[11,R[25],E,E,13,[[[U]],[R[4]]]],[11,R[26],E,E,13,[[],[R[4]]]],[11,R[27],E,E,13,[[["self"]],[T]]],[11,R[32],E,E,13,[[["self"]],[T]]],[11,R[30],E,E,13,[[["self"]],[R[33]]]],[11,"clone",R[24],E,1,[[["self"]],["gotovalue"]]],[11,"clone",E,E,2,[[["self"]],[R[11]]]],[11,"clone",R[34],E,6,[[["self"]],[R[36]]]],[11,"clone",E,E,7,[[["self"]],[R[37]]]],[11,"clone",E,E,10,[[["self"]],["instructiontype"]]],[11,"clone",E,E,8,[[["self"]],[R[38]]]],[11,"clone",E,E,9,[[["self"]],[R[3]]]],[11,"clone",R[35],E,13,[[["self"]],["statevalue"]]],[11,"fmt",R[31],"Formats the script error using the given formatter.",4,[[[R[39]],["self"]],[[R[4],["error"]],["error"]]]],[11,"fmt",R[24],E,1,[[[R[39]],["self"]],[R[4]]]],[11,"fmt",E,E,2,[[[R[39]],["self"]],[R[4]]]],[11,"fmt",R[31],E,5,[[[R[39]],["self"]],[R[4]]]],[11,"fmt",E,E,4,[[[R[39]],["self"]],[R[4]]]],[11,"fmt",R[34],E,6,[[[R[39]],["self"]],[R[4]]]],[11,"fmt",E,E,7,[[[R[39]],["self"]],[R[4]]]],[11,"fmt",E,E,10,[[[R[39]],["self"]],[R[4]]]],[11,"fmt",E,E,8,[[[R[39]],["self"]],[R[4]]]],[11,"fmt",E,E,9,[[[R[39]],["self"]],[R[4]]]],[11,"fmt",R[35],E,13,[[[R[39]],["self"]],[R[4]]]]],"p":[[3,R[40]],[4,R[41]],[4,R[42]],[8,"Command"],[3,R[43]],[4,R[44]],[3,R[45]],[3,R[46]],[3,R[47]],[3,R[48]],[4,R[49]],[3,"Context"],[3,R[50]],[4,R[51]]]}; +initSearch(searchIndex);addSearchOptions(searchIndex); \ No newline at end of file diff --git a/docs/api/duckscript/settings.css b/docs/api/duckscript/settings.css new file mode 100644 index 0000000..4201b26 --- /dev/null +++ b/docs/api/duckscript/settings.css @@ -0,0 +1 @@ +.setting-line{padding:5px;}.setting-line>div{max-width:calc(100% - 74px);display:inline-block;vertical-align:top;font-size:17px;padding-top:2px;}.toggle{position:relative;display:inline-block;width:45px;height:27px;margin-right:20px;}.toggle input{display:none;}.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;-webkit-transition:.3s;transition:.3s;}.slider:before{position:absolute;content:"";height:19px;width:19px;left:4px;bottom:4px;background-color:white;-webkit-transition:.3s;transition:.3s;}input:checked+.slider{background-color:#2196F3;}input:focus+.slider{box-shadow:0 0 1px #2196F3;}input:checked+.slider:before{-webkit-transform:translateX(19px);-ms-transform:translateX(19px);transform:translateX(19px);} \ No newline at end of file diff --git a/docs/api/duckscript/settings.html b/docs/api/duckscript/settings.html new file mode 100644 index 0000000..ea7cb83 --- /dev/null +++ b/docs/api/duckscript/settings.html @@ -0,0 +1 @@ +Rustdoc settings

Rustdoc settings

Auto-hide item declarations.
Auto-hide item attributes.
Auto-hide trait implementations documentation
Auto-hide item methods' documentation
Directly go to item in search if there is only one result
Show line numbers on code examples
\ No newline at end of file diff --git a/docs/api/duckscript/settings.js b/docs/api/duckscript/settings.js new file mode 100644 index 0000000..cfed84c --- /dev/null +++ b/docs/api/duckscript/settings.js @@ -0,0 +1 @@ +(function(){function changeSetting(settingName,isEnabled){updateLocalStorage('rustdoc-'+settingName,isEnabled);}function getSettingValue(settingName){return getCurrentValue('rustdoc-'+settingName);}function setEvents(){var elems=document.getElementsByClassName("slider");if(!elems||elems.length===0){return;}for(var i=0;i"){sidebar.style.left="";this.style.left="";child.innerText="<";updateLocalStorage("rustdoc-source-sidebar-show","true");}else{sidebar.style.left="-300px";this.style.left="0";child.innerText=">";updateLocalStorage("rustdoc-source-sidebar-show","false");}}function createSidebarToggle(){var sidebarToggle=document.createElement("div");sidebarToggle.id="sidebar-toggle";sidebarToggle.onclick=toggleSidebar;var inner1=document.createElement("div");inner1.style.position="relative";var inner2=document.createElement("div");inner2.style.paddingTop="3px";if(getCurrentValue("rustdoc-source-sidebar-show")==="true"){inner2.innerText="<";}else{inner2.innerText=">";sidebarToggle.style.left="0";}inner1.appendChild(inner2);sidebarToggle.appendChild(inner1);return sidebarToggle;}function createSourceSidebar(){if(window.rootPath.endsWith("/")===false){window.rootPath+="/";}var main=document.getElementById("main");var sidebarToggle=createSidebarToggle();main.insertBefore(sidebarToggle,main.firstChild);var sidebar=document.createElement("div");sidebar.id="source-sidebar";if(getCurrentValue("rustdoc-source-sidebar-show")!=="true"){sidebar.style.left="-300px";}var currentFile=getCurrentFilePath();var hasFoundFile=false;var title=document.createElement("div");title.className="title";title.innerText="Files";sidebar.appendChild(title);Object.keys(sourcesIndex).forEach(function(key){sourcesIndex[key].name=key;hasFoundFile=createDirEntry(sourcesIndex[key],sidebar,"",currentFile,hasFoundFile);});main.insertBefore(sidebar,main.firstChild);} \ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/expansion.rs.html b/docs/api/duckscript/src/duckscript/expansion.rs.html new file mode 100644 index 0000000..1498c7f --- /dev/null +++ b/docs/api/duckscript/src/duckscript/expansion.rs.html @@ -0,0 +1,233 @@ +expansion.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+
+//! # expansion
+//!
+//! The expand utility functions.
+//!
+
+#[cfg(test)]
+#[path = "./expansion_test.rs"]
+mod expansion_test;
+
+use crate::parser;
+use crate::types::instruction::InstructionMetaInfo;
+use std::collections::HashMap;
+
+pub(crate) enum ExpandedValue {
+    Single(String),
+    Multi(Vec<String>),
+    None,
+}
+
+fn should_break_key(value: char) -> bool {
+    value == ' ' || value == '\n' || value == '\t' || value == '\r' || value == '='
+}
+
+fn push_prefix(buffer: &mut String, single_type: bool, found_prefix_fully: bool) {
+    if single_type {
+        buffer.push('$');
+    } else {
+        buffer.push('%');
+    }
+
+    if found_prefix_fully {
+        buffer.push('{');
+    }
+}
+
+pub(crate) fn expand_by_wrapper(
+    value: &str,
+    meta_info: &InstructionMetaInfo,
+    variables: &HashMap<String, String>,
+) -> ExpandedValue {
+    let mut value_string = String::new();
+
+    let mut prefix_index = 0;
+    let mut found_prefix = false;
+    let mut key = String::new();
+    let mut force_push = false;
+    let mut single_type = true;
+    for next_char in value.chars() {
+        if !found_prefix {
+            if next_char == '\\' && prefix_index == 0 {
+                // skip this character
+                force_push = true
+            } else if force_push {
+                value_string.push(next_char);
+                force_push = false;
+            } else if prefix_index == 0 && (next_char == '$' || next_char == '%') {
+                prefix_index = 1;
+
+                single_type = if next_char == '$' { true } else { false };
+            } else if prefix_index == 1 && next_char == '{' {
+                found_prefix = true;
+                prefix_index = 0;
+                key.clear();
+            } else {
+                if prefix_index > 0 || found_prefix {
+                    push_prefix(&mut value_string, single_type, found_prefix);
+                    prefix_index = 0;
+                }
+                value_string.push(next_char);
+            }
+        } else if next_char == '}' {
+            match variables.get(&key) {
+                Some(variable_value) => value_string.push_str(&variable_value),
+                _ => (),
+            };
+
+            key.clear();
+            found_prefix = false;
+        } else if should_break_key(next_char) {
+            if prefix_index > 0 || found_prefix {
+                push_prefix(&mut value_string, single_type, found_prefix);
+                prefix_index = 0;
+            }
+            value_string.push_str(&key);
+            value_string.push(next_char);
+
+            key.clear();
+            found_prefix = false;
+        } else {
+            key.push(next_char);
+        }
+    }
+
+    if key.len() > 0 {
+        if prefix_index > 0 || found_prefix {
+            push_prefix(&mut value_string, single_type, found_prefix);
+        }
+        value_string.push_str(&key);
+    }
+
+    if value_string.is_empty() {
+        ExpandedValue::None
+    } else if single_type {
+        ExpandedValue::Single(value_string.to_string())
+    } else {
+        let chars = value_string.to_string().chars().collect();
+        match parser::parse_arguments(meta_info, &chars, 0) {
+            Ok(values_option) => match values_option {
+                Some(values) => ExpandedValue::Multi(values),
+                None => ExpandedValue::None,
+            },
+            Err(_) => ExpandedValue::None,
+        }
+    }
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/io.rs.html b/docs/api/duckscript/src/duckscript/io.rs.html new file mode 100644 index 0000000..103cfe1 --- /dev/null +++ b/docs/api/duckscript/src/duckscript/io.rs.html @@ -0,0 +1,61 @@ +io.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+
+//! # io
+//!
+//! IO helper functions
+//!
+
+#[cfg(test)]
+#[path = "./io_test.rs"]
+mod io_test;
+
+use crate::types::error::{ErrorInfo, ScriptError};
+use std::fs::File;
+use std::io::Read;
+use std::path::Path;
+
+pub(crate) fn read_text_file(file: &str) -> Result<String, ScriptError> {
+    let file_path = Path::new(file);
+
+    match File::open(&file_path) {
+        Ok(mut fd) => {
+            let mut content = String::new();
+            fd.read_to_string(&mut content).unwrap();
+
+            Ok(content)
+        }
+        Err(error) => Err(ScriptError {
+            info: ErrorInfo::ErrorReadingFile(file.to_string(), Some(error)),
+        }),
+    }
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/lib.rs.html b/docs/api/duckscript/src/duckscript/lib.rs.html new file mode 100644 index 0000000..ffe3ce3 --- /dev/null +++ b/docs/api/duckscript/src/duckscript/lib.rs.html @@ -0,0 +1,269 @@ +lib.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+
+#![deny(
+    absolute_paths_not_starting_with_crate,
+    ambiguous_associated_items,
+    anonymous_parameters,
+    const_err,
+    dead_code,
+    deprecated,
+    deprecated_in_future,
+    duplicate_macro_exports,
+    ellipsis_inclusive_range_patterns,
+    exceeding_bitshifts,
+    explicit_outlives_requirements,
+    exported_private_dependencies,
+    ill_formed_attribute_input,
+    illegal_floating_point_literal_pattern,
+    improper_ctypes,
+    indirect_structural_match,
+    invalid_type_param_default,
+    irrefutable_let_patterns,
+    keyword_idents,
+    late_bound_lifetime_arguments,
+    legacy_constructor_visibility,
+    legacy_directory_ownership,
+    macro_expanded_macro_exports_accessed_by_absolute_paths,
+    missing_copy_implementations,
+    missing_docs,
+    missing_fragment_specifier,
+    mutable_borrow_reservation_conflict,
+    mutable_transmutes,
+    nested_impl_trait,
+    no_mangle_const_items,
+    no_mangle_generic_items,
+    non_ascii_idents,
+    non_camel_case_types,
+    non_shorthand_field_patterns,
+    non_snake_case,
+    non_upper_case_globals,
+    order_dependent_trait_objects,
+    overflowing_literals,
+    parenthesized_params_in_types_and_modules,
+    path_statements,
+    patterns_in_fns_without_body,
+    plugin_as_library,
+    private_doc_tests,
+    private_in_public,
+    proc_macro_derive_resolution_fallback,
+    pub_use_of_private_extern_crate,
+    safe_extern_statics,
+    safe_packed_borrows,
+    stable_features,
+    trivial_bounds,
+    trivial_casts,
+    trivial_numeric_casts,
+    type_alias_bounds,
+    tyvar_behind_raw_pointer,
+    unconditional_recursion,
+    unions_with_drop_fields,
+    unknown_crate_types,
+    unnameable_test_items,
+    unreachable_code,
+    unreachable_patterns,
+    unreachable_pub,
+    unsafe_code,
+    unstable_features,
+    unstable_name_collisions,
+    unused_allocation,
+    unused_assignments,
+    unused_attributes,
+    unused_comparisons,
+    unused_doc_comments,
+    unused_extern_crates,
+    unused_features,
+    unused_import_braces,
+    unused_imports,
+    unused_labels,
+    unused_lifetimes,
+    unused_macros,
+    unused_must_use,
+    unused_mut,
+    unused_parens,
+    unused_qualifications,
+    unused_unsafe,
+    unused_variables,
+    where_clauses_object_safety,
+    while_true
+)]
+#![warn(macro_use_extern_crate, unknown_lints)]
+#![allow(
+    bare_trait_objects,
+    box_pointers,
+    elided_lifetimes_in_paths,
+    intra_doc_link_resolution_failure,
+    missing_doc_code_examples,
+    missing_debug_implementations,
+    single_use_lifetimes,
+    unused_results,
+    variant_size_differences,
+    warnings,
+    renamed_and_removed_lints
+)]
+
+//! # duckscript
+//!
+//! Simple, extendable and embeddable scripting language.
+//!
+//! This library is the actual script parser and runner.<br>
+//! On it's own, it has no actual commands as those need to be provided externally (see duckscript_sdk).
+//!
+//! # Installation
+//! In order to use this library, just add it as a dependency:
+//!
+//! ```ini
+//! [dependencies]
+//! duckscript = "*"
+//! ```
+//!
+//! # Contributing
+//! See [contributing guide](https://github.com/sagiegurari/duckscript/blob/master/.github/CONTRIBUTING.md)
+//!
+//! # License
+//! Developed by Sagie Gur-Ari and licensed under the
+//! [Apache 2](https://github.com/sagiegurari/duckscript/blob/master/LICENSE) open source license.
+//!
+
+mod expansion;
+mod io;
+pub mod parser;
+mod preprocessor;
+pub mod runner;
+pub mod types;
+
+#[cfg(test)]
+mod test;
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/parser.rs.html b/docs/api/duckscript/src/duckscript/parser.rs.html new file mode 100644 index 0000000..9337070 --- /dev/null +++ b/docs/api/duckscript/src/duckscript/parser.rs.html @@ -0,0 +1,937 @@ +parser.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+
+//! # parser
+//!
+//! The duck script parser.
+//!
+
+#[cfg(test)]
+#[path = "./parser_test.rs"]
+mod parser_test;
+
+use crate::io;
+use crate::preprocessor;
+use crate::types::error::{ErrorInfo, ScriptError};
+use crate::types::instruction::{
+    Instruction, InstructionMetaInfo, InstructionType, PreProcessInstruction, ScriptInstruction,
+};
+
+static COMMENT_PREFIX_STR: &str = "#";
+static PRE_PROCESS_PREFIX: char = '!';
+static LABEL_PREFIX: char = ':';
+
+/// parses the file and returns a vector of instructions
+pub fn parse_file(file: &str) -> Result<Vec<Instruction>, ScriptError> {
+    let mut meta_info = InstructionMetaInfo::new();
+    meta_info.source = Some(file.to_string());
+
+    match io::read_text_file(file) {
+        Ok(text) => parse_lines(&text, meta_info),
+        Err(error) => Err(error),
+    }
+}
+
+/// parses the provided script text and returns a vector of instructions
+pub fn parse_text(text: &str) -> Result<Vec<Instruction>, ScriptError> {
+    parse_lines(&text, InstructionMetaInfo::new())
+}
+
+fn parse_lines(
+    lines: &str,
+    meta_info: InstructionMetaInfo,
+) -> Result<Vec<Instruction>, ScriptError> {
+    let mut instructions = vec![];
+
+    let mut line_number = 1;
+    for line in lines.lines() {
+        let mut line_meta_info = meta_info.clone();
+        line_meta_info.line = Some(line_number);
+        line_number = line_number + 1;
+
+        match parse_line(&line, line_meta_info) {
+            Ok(instruction) => {
+                instructions.push(instruction.clone());
+
+                match instruction.instruction_type {
+                    InstructionType::PreProcess(_) => match preprocessor::run(&instruction) {
+                        Ok(mut added_instructions) => instructions.append(&mut added_instructions),
+                        Err(error) => return Err(error),
+                    },
+                    _ => (),
+                }
+            }
+            Err(error) => return Err(error),
+        };
+    }
+
+    Ok(instructions)
+}
+
+fn parse_line(line_text: &str, meta_info: InstructionMetaInfo) -> Result<Instruction, ScriptError> {
+    let trimmed_text = line_text.trim();
+
+    if trimmed_text.is_empty() || trimmed_text.starts_with(&COMMENT_PREFIX_STR) {
+        Ok(Instruction {
+            meta_info,
+            instruction_type: InstructionType::Empty,
+        })
+    } else {
+        let chars: Vec<char> = trimmed_text.chars().collect();
+
+        if chars[0] == PRE_PROCESS_PREFIX {
+            parse_pre_process_line(&chars, meta_info, 1)
+        } else {
+            parse_command_line(&chars, meta_info, 0)
+        }
+    }
+}
+
+fn parse_pre_process_line(
+    line_text: &Vec<char>,
+    meta_info: InstructionMetaInfo,
+    start_index: usize,
+) -> Result<Instruction, ScriptError> {
+    if line_text.is_empty() {
+        Err(ScriptError {
+            info: ErrorInfo::PreProcessNoCommandFound(meta_info),
+        })
+    } else {
+        let mut command = String::new();
+        let mut index = start_index;
+        let end_index = line_text.len();
+        for _i in index..end_index {
+            let character = line_text[index];
+            index = index + 1;
+
+            if character == ' ' {
+                if !command.is_empty() {
+                    break;
+                }
+            } else {
+                command.push(character);
+            }
+        }
+
+        if command.is_empty() {
+            Err(ScriptError {
+                info: ErrorInfo::PreProcessNoCommandFound(meta_info),
+            })
+        } else {
+            match parse_arguments(&meta_info, &line_text, index) {
+                Ok(arguments) => {
+                    let mut instruction = PreProcessInstruction::new();
+                    instruction.command = Some(command);
+                    instruction.arguments = arguments;
+
+                    Ok(Instruction {
+                        meta_info,
+                        instruction_type: InstructionType::PreProcess(instruction),
+                    })
+                }
+                Err(error) => Err(error),
+            }
+        }
+    }
+}
+
+fn parse_command_line(
+    line_text: &Vec<char>,
+    meta_info: InstructionMetaInfo,
+    start_index: usize,
+) -> Result<Instruction, ScriptError> {
+    let end_index = line_text.len();
+
+    if line_text.is_empty() || start_index >= end_index {
+        Ok(Instruction {
+            meta_info,
+            instruction_type: InstructionType::Empty,
+        })
+    } else {
+        // search for label
+        let mut index = start_index;
+        let mut instruction = ScriptInstruction::new();
+        match find_label(&meta_info, &line_text, index) {
+            Ok(output) => {
+                let (next_index, value) = output;
+                index = next_index;
+
+                if value.is_some() {
+                    instruction.label = value.clone();
+                }
+            }
+            Err(error) => return Err(error),
+        };
+
+        // find output variable and command
+        index = match find_output_and_command(&meta_info, &line_text, index, &mut instruction) {
+            Ok(next_index) => next_index,
+            Err(error) => return Err(error),
+        };
+
+        match parse_arguments(&meta_info, &line_text, index) {
+            Ok(arguments) => {
+                instruction.arguments = arguments;
+
+                let instruction_type = if instruction.label.is_none()
+                    && instruction.output.is_none()
+                    && instruction.command.is_none()
+                {
+                    InstructionType::Empty
+                } else {
+                    InstructionType::Script(instruction)
+                };
+
+                Ok(Instruction {
+                    meta_info,
+                    instruction_type,
+                })
+            }
+            Err(error) => Err(error),
+        }
+    }
+}
+
+pub(crate) fn parse_arguments(
+    meta_info: &InstructionMetaInfo,
+    line_text: &Vec<char>,
+    start_index: usize,
+) -> Result<Option<Vec<String>>, ScriptError> {
+    let mut arguments = vec![];
+
+    let mut index = start_index;
+    loop {
+        match parse_next_argument(&meta_info, &line_text, index) {
+            Ok(output) => {
+                let (next_index, argument) = output;
+
+                if argument.is_none() {
+                    break;
+                }
+
+                arguments.push(argument.unwrap());
+                index = next_index;
+            }
+            Err(error) => return Err(error),
+        }
+    }
+
+    if arguments.is_empty() {
+        Ok(None)
+    } else {
+        Ok(Some(arguments))
+    }
+}
+
+fn parse_next_argument(
+    meta_info: &InstructionMetaInfo,
+    line_text: &Vec<char>,
+    start_index: usize,
+) -> Result<(usize, Option<String>), ScriptError> {
+    parse_next_value(&meta_info, &line_text, start_index, true, true, false)
+}
+
+fn parse_next_value(
+    meta_info: &InstructionMetaInfo,
+    line_text: &Vec<char>,
+    start_index: usize,
+    allow_quotes: bool,
+    allow_control: bool,
+    stop_on_equals: bool,
+) -> Result<(usize, Option<String>), ScriptError> {
+    let end_index = line_text.len();
+
+    if start_index >= end_index {
+        Ok((start_index, None))
+    } else {
+        let mut argument = String::new();
+        let mut index = start_index;
+        let mut in_argument = false;
+        let mut using_quotes = false;
+        let mut in_control = false;
+        let mut found_end = false;
+        let mut found_variable_prefix = false;
+        for _i in index..end_index {
+            let character = line_text[index];
+            index = index + 1;
+
+            if in_argument {
+                if in_control {
+                    if found_variable_prefix {
+                        if character == '{' {
+                            argument.push_str("\\${");
+                            in_control = false;
+                            found_variable_prefix = false;
+                        } else {
+                            return Err(ScriptError {
+                                info: ErrorInfo::ControlWithoutValidValue(meta_info.clone()),
+                            });
+                        }
+                    } else if character == '\\' || character == '"' {
+                        argument.push(character);
+                        in_control = false;
+                    } else if character == 'n' {
+                        argument.push('\n');
+                        in_control = false;
+                    } else if character == 'r' {
+                        argument.push('\r');
+                        in_control = false;
+                    } else if character == 't' {
+                        argument.push('\t');
+                        in_control = false;
+                    } else if character == '$' {
+                        found_variable_prefix = true;
+                    } else {
+                        return Err(ScriptError {
+                            info: ErrorInfo::ControlWithoutValidValue(meta_info.clone()),
+                        });
+                    }
+                } else if character == '\\' {
+                    if allow_control {
+                        in_control = true;
+                        found_variable_prefix = false;
+                    } else {
+                        return Err(ScriptError {
+                            info: ErrorInfo::InvalidControlLocation(meta_info.clone()),
+                        });
+                    }
+                } else if using_quotes && character == '"' {
+                    found_end = true;
+                    break;
+                } else if !using_quotes
+                    && (character == ' '
+                        || character == '#'
+                        || (stop_on_equals && character == '='))
+                {
+                    if character == ' ' || character == '=' {
+                        index = index - 1;
+                    } else if character == '#' {
+                        index = end_index;
+                    }
+                    found_end = true;
+                    break;
+                } else {
+                    argument.push(character);
+                }
+            } else if character == '#' {
+                index = end_index;
+                break;
+            } else if character != ' ' {
+                in_argument = true;
+
+                if character == '"' {
+                    if allow_quotes {
+                        using_quotes = true;
+                    } else {
+                        return Err(ScriptError {
+                            info: ErrorInfo::InvalidQuotesLocation(meta_info.clone()),
+                        });
+                    }
+                } else if character == '\\' {
+                    if allow_control {
+                        in_control = true;
+                    } else {
+                        return Err(ScriptError {
+                            info: ErrorInfo::InvalidControlLocation(meta_info.clone()),
+                        });
+                    }
+                } else {
+                    argument.push(character);
+                }
+            }
+        }
+
+        if in_argument && !found_end && (in_control || using_quotes) {
+            if in_control {
+                Err(ScriptError {
+                    info: ErrorInfo::ControlWithoutValidValue(meta_info.clone()),
+                })
+            } else {
+                Err(ScriptError {
+                    info: ErrorInfo::MissingEndQuotes(meta_info.clone()),
+                })
+            }
+        } else if argument.is_empty() {
+            if using_quotes {
+                Ok((index, Some(argument)))
+            } else {
+                Ok((index, None))
+            }
+        } else {
+            Ok((index, Some(argument)))
+        }
+    }
+}
+
+fn find_label(
+    meta_info: &InstructionMetaInfo,
+    line_text: &Vec<char>,
+    start_index: usize,
+) -> Result<(usize, Option<String>), ScriptError> {
+    let end_index = line_text.len();
+
+    if start_index >= end_index {
+        Ok((start_index, None))
+    } else {
+        let mut label = None;
+        let mut index = start_index;
+        for _i in index..end_index {
+            let character = line_text[index];
+            index = index + 1;
+
+            if character == LABEL_PREFIX {
+                match parse_next_value(&meta_info, &line_text, index, false, false, false) {
+                    Ok(output) => {
+                        let (next_index, value) = output;
+                        index = next_index;
+
+                        match value {
+                            Some(label_value) => {
+                                if label_value.is_empty() {
+                                    return Err(ScriptError {
+                                        info: ErrorInfo::EmptyLabel(meta_info.clone()),
+                                    });
+                                }
+
+                                let mut text = String::new();
+                                text.push(LABEL_PREFIX);
+                                text.push_str(&label_value);
+
+                                label = Some(text);
+                            }
+                            None => (),
+                        };
+
+                        break;
+                    }
+                    Err(error) => return Err(error),
+                };
+            } else if character != ' ' {
+                index = index - 1;
+                break;
+            }
+        }
+
+        Ok((index, label))
+    }
+}
+
+fn find_output_and_command(
+    meta_info: &InstructionMetaInfo,
+    line_text: &Vec<char>,
+    start_index: usize,
+    instruction: &mut ScriptInstruction,
+) -> Result<usize, ScriptError> {
+    match parse_next_value(&meta_info, &line_text, start_index, false, false, true) {
+        Ok(output) => {
+            let (next_index, value) = output;
+
+            if value.is_none() {
+                Ok(next_index)
+            } else {
+                let mut index = next_index;
+                let end_index = line_text.len();
+                for _i in index..end_index {
+                    let character = line_text[index];
+                    index = index + 1;
+
+                    if character != ' ' {
+                        if character == '=' {
+                            instruction.output = value.clone();
+                        }
+
+                        break;
+                    }
+                }
+
+                if instruction.output.is_some() {
+                    match parse_next_value(&meta_info, &line_text, index, false, false, false) {
+                        Ok(output) => {
+                            let (next_index, value) = output;
+
+                            if value.is_none() {
+                                Ok(index)
+                            } else {
+                                instruction.command = value.clone();
+                                Ok(next_index)
+                            }
+                        }
+                        Err(error) => Err(error),
+                    }
+                } else {
+                    instruction.command = value.clone();
+
+                    Ok(next_index)
+                }
+            }
+        }
+        Err(error) => Err(error),
+    }
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/preprocessor/include_files_preprocessor.rs.html b/docs/api/duckscript/src/duckscript/preprocessor/include_files_preprocessor.rs.html new file mode 100644 index 0000000..f63b8cb --- /dev/null +++ b/docs/api/duckscript/src/duckscript/preprocessor/include_files_preprocessor.rs.html @@ -0,0 +1,113 @@ +include_files_preprocessor.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+
+//! # include_files_preprocessor
+//!
+//! Enables to load and include additional source files.
+//!
+
+use crate::parser;
+use crate::types::error::ScriptError;
+use crate::types::instruction::{Instruction, InstructionMetaInfo};
+use std::path::PathBuf;
+
+pub(crate) fn run(
+    arguments: &Option<Vec<String>>,
+    meta_info: &InstructionMetaInfo,
+) -> Result<Vec<Instruction>, ScriptError> {
+    let mut instructions = vec![];
+
+    if let Some(arguments_vec) = arguments {
+        for argument in arguments_vec {
+            // get file based on parent file location
+            let file_path = if argument.starts_with("/") || argument.starts_with("\\") {
+                argument.to_string()
+            } else {
+                match &meta_info.source {
+                    Some(value) => {
+                        let path_buffer = PathBuf::from(&value);
+                        match path_buffer.parent() {
+                            Some(path) => {
+                                let mut parent_path_buffer = path.to_path_buf();
+                                parent_path_buffer.push(&argument);
+
+                                let full_path_buffer = match parent_path_buffer.canonicalize() {
+                                    Ok(new_buffer) => new_buffer,
+                                    _ => parent_path_buffer,
+                                };
+
+                                full_path_buffer.to_string_lossy().into_owned()
+                            }
+                            _ => argument.to_string(),
+                        }
+                    }
+                    None => argument.to_string(),
+                }
+            };
+
+            match parser::parse_file(&file_path) {
+                Ok(mut additional_instructions) => {
+                    instructions.append(&mut additional_instructions)
+                }
+                Err(error) => return Err(error),
+            }
+        }
+    }
+
+    Ok(instructions)
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/preprocessor/mod.rs.html b/docs/api/duckscript/src/duckscript/preprocessor/mod.rs.html new file mode 100644 index 0000000..78d16fe --- /dev/null +++ b/docs/api/duckscript/src/duckscript/preprocessor/mod.rs.html @@ -0,0 +1,81 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+
+//! # preprocessor
+//!
+//! The pre processor is invoked on parse time by the script parser.
+//! Currently it provide only limited amount of commands and it is not meant to be extendable.
+//!
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+mod include_files_preprocessor;
+mod print_preprocessor;
+
+use crate::types::error::{ErrorInfo, ScriptError};
+use crate::types::instruction::{Instruction, InstructionType};
+
+pub(crate) fn run(instruction: &Instruction) -> Result<Vec<Instruction>, ScriptError> {
+    match instruction.instruction_type {
+        InstructionType::PreProcess(ref instruction_type) => match &instruction_type.command {
+            Some(command) => match command.as_ref() {
+                "print" => {
+                    print_preprocessor::run(&instruction_type.arguments);
+                    Ok(vec![])
+                }
+                "include_files" => include_files_preprocessor::run(
+                    &instruction_type.arguments,
+                    &instruction.meta_info,
+                ),
+                _ => Err(ScriptError {
+                    info: ErrorInfo::UnknownPreProcessorCommand(instruction.meta_info.clone()),
+                }),
+            },
+            None => Err(ScriptError {
+                info: ErrorInfo::PreProcessNoCommandFound(instruction.meta_info.clone()),
+            }),
+        },
+        _ => Ok(vec![]),
+    }
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/preprocessor/print_preprocessor.rs.html b/docs/api/duckscript/src/duckscript/preprocessor/print_preprocessor.rs.html new file mode 100644 index 0000000..15889be --- /dev/null +++ b/docs/api/duckscript/src/duckscript/preprocessor/print_preprocessor.rs.html @@ -0,0 +1,31 @@ +print_preprocessor.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+
+//! # print_preprocessor
+//!
+//! The print pre processor implementation.
+//!
+
+pub(crate) fn run(arguments: &Option<Vec<String>>) {
+    if let Some(arguments_vec) = arguments {
+        for argument in arguments_vec {
+            print!("{} ", argument);
+        }
+    }
+
+    println!("");
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/runner.rs.html b/docs/api/duckscript/src/duckscript/runner.rs.html new file mode 100644 index 0000000..9956930 --- /dev/null +++ b/docs/api/duckscript/src/duckscript/runner.rs.html @@ -0,0 +1,591 @@ +runner.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+
+//! # runner
+//!
+//! The main entry point which enables running scripts.
+//!
+
+#[cfg(test)]
+#[path = "./runner_test.rs"]
+mod runner_test;
+
+use crate::expansion::{self, ExpandedValue};
+use crate::parser;
+use crate::types::command::{CommandResult, Commands, GoToValue};
+use crate::types::error::{ErrorInfo, ScriptError};
+use crate::types::instruction::{
+    Instruction, InstructionMetaInfo, InstructionType, ScriptInstruction,
+};
+use crate::types::runtime::{Context, Runtime, StateValue};
+use std::collections::HashMap;
+
+/// Executes the provided script with the given context
+pub fn run_script(text: &str, context: Context) -> Result<Context, ScriptError> {
+    match parser::parse_text(text) {
+        Ok(instructions) => run(instructions, context),
+        Err(error) => Err(error),
+    }
+}
+
+/// Executes the provided script file with the given context
+pub fn run_script_file(file: &str, context: Context) -> Result<Context, ScriptError> {
+    match parser::parse_file(file) {
+        Ok(instructions) => run(instructions, context),
+        Err(error) => Err(error),
+    }
+}
+
+fn run(instructions: Vec<Instruction>, context: Context) -> Result<Context, ScriptError> {
+    let runtime = create_runtime(instructions, context);
+
+    run_instructions(runtime, 0)
+}
+
+fn create_runtime(instructions: Vec<Instruction>, context: Context) -> Runtime {
+    let mut runtime = Runtime::new(context);
+
+    let mut line = 0;
+    for instruction in &instructions {
+        match &instruction.instruction_type {
+            InstructionType::Script(ref value) => {
+                match value.label {
+                    Some(ref label) => {
+                        runtime.label_to_line.insert(label.to_string(), line);
+                        ()
+                    }
+                    None => (),
+                };
+            }
+            _ => (),
+        };
+
+        line = line + 1;
+    }
+
+    runtime.instructions = Some(instructions);
+
+    runtime
+}
+
+fn run_instructions(mut runtime: Runtime, start_at: usize) -> Result<Context, ScriptError> {
+    let mut line = start_at;
+    let mut state = runtime.context.state.clone();
+
+    let instructions = match runtime.instructions {
+        Some(ref instructions) => instructions,
+        None => return Ok(runtime.context),
+    };
+
+    loop {
+        let (instruction, meta_info) = if instructions.len() > line {
+            let instruction = instructions[line].clone();
+            let meta_info = instruction.meta_info.clone();
+            (instruction, meta_info)
+        } else {
+            break;
+        };
+
+        let (command_result, output_variable) = run_instruction(
+            &mut runtime.context.commands,
+            &mut runtime.context.variables,
+            &mut state,
+            &instructions,
+            instruction,
+            line,
+        );
+
+        match command_result {
+            CommandResult::Exit(output) => {
+                update_output(&mut runtime.context.variables, output_variable, output);
+
+                break;
+            }
+            CommandResult::Error(error) => {
+                update_output(
+                    &mut runtime.context.variables,
+                    output_variable,
+                    Some("false".to_string()),
+                );
+
+                let post_error_line = line + 1;
+
+                let should_continue = run_on_error_instruction(
+                    &mut runtime.context.commands,
+                    &mut runtime.context.variables,
+                    &mut state,
+                    &instructions,
+                    error,
+                    meta_info,
+                );
+
+                if !should_continue {
+                    break;
+                }
+
+                line = post_error_line;
+
+                ()
+            }
+            CommandResult::Crash(error) => {
+                return Err(ScriptError {
+                    info: ErrorInfo::Runtime(error, Some(meta_info)),
+                });
+            }
+            CommandResult::Continue(output) => {
+                update_output(&mut runtime.context.variables, output_variable, output);
+
+                line = line + 1;
+
+                ()
+            }
+            CommandResult::GoTo(output, goto_value) => {
+                update_output(&mut runtime.context.variables, output_variable, output);
+
+                match goto_value {
+                    GoToValue::Label(label) => match runtime.label_to_line.get(&label) {
+                        Some(value) => line = *value,
+                        None => {
+                            return Err(ScriptError {
+                                info: ErrorInfo::Runtime(
+                                    format!("Label: {} not found.", label),
+                                    Some(meta_info),
+                                ),
+                            });
+                        }
+                    },
+                    GoToValue::Line(line_number) => line = line_number,
+                }
+            }
+        };
+    }
+
+    runtime.context.state = state;
+
+    Ok(runtime.context)
+}
+
+fn update_output(
+    variables: &mut HashMap<String, String>,
+    output_variable: Option<String>,
+    output: Option<String>,
+) {
+    if output_variable.is_some() {
+        match output {
+            Some(value) => variables.insert(output_variable.unwrap(), value),
+            None => variables.remove(&output_variable.unwrap()),
+        };
+    }
+}
+
+fn run_on_error_instruction(
+    commands: &mut Commands,
+    variables: &mut HashMap<String, String>,
+    state: &mut HashMap<String, StateValue>,
+    instructions: &Vec<Instruction>,
+    error: String,
+    meta_info: InstructionMetaInfo,
+) -> bool {
+    if commands.exists("on_error") {
+        let mut script_instruction = ScriptInstruction::new();
+        script_instruction.command = Some("on_error".to_string());
+        script_instruction.arguments = Some(vec![
+            error,
+            meta_info.line.unwrap_or(0).to_string(),
+            meta_info.source.unwrap_or("".to_string()),
+        ]);
+        let instruction = Instruction {
+            meta_info: InstructionMetaInfo::new(),
+            instruction_type: InstructionType::Script(script_instruction),
+        };
+
+        let (command_result, output_variable) =
+            run_instruction(commands, variables, state, instructions, instruction, 0);
+
+        match command_result {
+            CommandResult::Exit(output) => {
+                update_output(variables, output_variable, output);
+
+                false
+            }
+            CommandResult::Crash(_) => false,
+            _ => true,
+        }
+    } else {
+        true
+    }
+}
+
+/// Enables to evaluate a single instruction and return its result.
+pub fn run_instruction(
+    commands: &mut Commands,
+    variables: &mut HashMap<String, String>,
+    state: &mut HashMap<String, StateValue>,
+    instructions: &Vec<Instruction>,
+    instruction: Instruction,
+    line: usize,
+) -> (CommandResult, Option<String>) {
+    let mut output_variable = None;
+    let command_result = match instruction.instruction_type {
+        InstructionType::Empty => CommandResult::Continue(None),
+        InstructionType::PreProcess(_) => CommandResult::Continue(None),
+        InstructionType::Script(ref script_instruction) => {
+            output_variable = script_instruction.output.clone();
+
+            match script_instruction.command {
+                Some(ref command) => match commands.get_for_use(command) {
+                    Some(command_instance) => {
+                        let command_arguments = bind_command_arguments(
+                            &variables,
+                            &script_instruction,
+                            &instruction.meta_info,
+                        );
+
+                        let command_result = if command_instance.requires_context() {
+                            command_instance.run_with_context(
+                                command_arguments,
+                                state,
+                                variables,
+                                output_variable.clone(),
+                                &instructions,
+                                commands,
+                                line,
+                            )
+                        } else {
+                            command_instance.run(command_arguments)
+                        };
+
+                        commands.return_after_usage(command_instance);
+
+                        command_result
+                    }
+                    None => CommandResult::Error(format!("Command: {} not found.", &command)),
+                },
+                None => CommandResult::Continue(None),
+            }
+        }
+    };
+
+    (command_result, output_variable)
+}
+
+fn bind_command_arguments(
+    variables: &HashMap<String, String>,
+    instruction: &ScriptInstruction,
+    meta_info: &InstructionMetaInfo,
+) -> Vec<String> {
+    let mut arguments = vec![];
+
+    match instruction.arguments {
+        Some(ref arguments_ref) => {
+            for argument in arguments_ref {
+                match expansion::expand_by_wrapper(&argument, meta_info, variables) {
+                    ExpandedValue::Single(value) => arguments.push(value),
+                    ExpandedValue::Multi(values) => {
+                        for value in values {
+                            arguments.push(value)
+                        }
+                    }
+                    ExpandedValue::None => arguments.push("".to_string()),
+                }
+            }
+        }
+        None => (),
+    };
+
+    arguments
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/types/command.rs.html b/docs/api/duckscript/src/duckscript/types/command.rs.html new file mode 100644 index 0000000..23243cf --- /dev/null +++ b/docs/api/duckscript/src/duckscript/types/command.rs.html @@ -0,0 +1,397 @@ +command.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+
+//! # command
+//!
+//! The command trait and access module.
+//!
+
+#[cfg(test)]
+#[path = "./command_test.rs"]
+mod command_test;
+
+use crate::types::error::{ErrorInfo, ScriptError};
+use crate::types::instruction::Instruction;
+use crate::types::runtime::StateValue;
+use std::collections::HashMap;
+
+/// GoTo type value
+#[derive(Debug, Clone)]
+pub enum GoToValue {
+    /// label target
+    Label(String),
+    /// Line number
+    Line(usize),
+}
+
+/// Command execution result
+#[derive(Debug, Clone)]
+pub enum CommandResult {
+    /// Holds the command output and tells the runner to continue to next instruction
+    Continue(Option<String>),
+    /// Holds the command output and tells the runner to jump to the provided label
+    GoTo(Option<String>, GoToValue),
+    /// Holds the error message and the meta info of the instruction that caused it
+    Error(String),
+    /// Holds the critical error message and the meta info of the instruction that caused it
+    Crash(String),
+    /// Holds the command output and tells the runner to stop the script execution
+    Exit(Option<String>),
+}
+
+/// Defines the command capabilities
+pub trait Command {
+    /// The full command name which can be used to invoke this command.
+    fn name(&self) -> String;
+
+    /// A list of aliases that can also be used to invoke this command.
+    fn aliases(&self) -> Vec<String> {
+        vec![]
+    }
+
+    /// Command documentation.
+    fn help(&self) -> String {
+        format!("No documentation found for command: {}", self.name())
+    }
+
+    /// If true the run with the context will be invoked.
+    fn requires_context(&self) -> bool {
+        false
+    }
+
+    /// Runs the given instruction
+    fn run(&self, _arguments: Vec<String>) -> CommandResult {
+        CommandResult::Error(format!("Not implemented for command: {}", &self.name()).to_string())
+    }
+
+    /// Run the instruction with access to the runtime context.
+    ///
+    /// # Arguments
+    ///
+    /// * `arguments` - The command arguments array
+    /// * `state` - Internal state which is only used by commands to store/pull data
+    /// * `variables` - All script variables
+    /// * `output_variable` - The output variable name (if defined)
+    /// * `instructions` - The entire list of instructions which make up the currently running script
+    /// * `commands` - The currently known commands
+    /// * `line` - The current instruction line number (global line number after including all scripts into one global script)
+    fn run_with_context(
+        &self,
+        _arguments: Vec<String>,
+        _state: &mut HashMap<String, StateValue>,
+        _variables: &mut HashMap<String, String>,
+        _output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _line: usize,
+    ) -> CommandResult {
+        CommandResult::Error(format!("Not implemented for command: {}", &self.name()).to_string())
+    }
+}
+
+/// Holds and enables access to the runtime commands implementations
+pub struct Commands {
+    /// mapping between command names to implementations
+    pub commands: HashMap<String, Box<dyn Command>>,
+    /// mapping between aliases to command names
+    pub aliases: HashMap<String, String>,
+}
+
+impl Commands {
+    /// Creates and returns a new instance.
+    pub fn new() -> Commands {
+        Commands {
+            commands: HashMap::new(),
+            aliases: HashMap::new(),
+        }
+    }
+
+    /// Returns the command after it was being used.
+    /// No validations will be made.
+    pub fn return_after_usage(&mut self, command: Box<dyn Command>) {
+        let name = command.name();
+
+        self.commands.insert(name.clone(), command);
+    }
+
+    /// Adds a new command definition.
+    /// It will fail in case another command already defined the same name/aliases
+    pub fn set(&mut self, command: Box<dyn Command>) -> Result<(), ScriptError> {
+        let name = command.name();
+        let aliases = command.aliases();
+
+        if self.commands.contains_key(&name) {
+            return Err(ScriptError {
+                info: ErrorInfo::Initialization(format!("Command: {} already defined.", &name)),
+            });
+        }
+
+        for alias in &aliases {
+            if self.aliases.contains_key(alias) {
+                return Err(ScriptError {
+                    info: ErrorInfo::Initialization(format!(
+                        "Alias: {} for command: {} already defined.",
+                        &alias, &name
+                    )),
+                });
+            }
+        }
+
+        self.commands.insert(name.clone(), command);
+
+        for alias in &aliases {
+            self.aliases.insert(alias.to_string(), name.clone());
+        }
+
+        Ok(())
+    }
+
+    /// Return the command based on the given command name/alias
+    pub fn get(&self, name: &str) -> Option<&Box<dyn Command>> {
+        let command_name = match self.aliases.get(name) {
+            Some(ref value) => value,
+            None => name,
+        };
+
+        match self.commands.get(command_name) {
+            Some(ref value) => Some(value.clone()),
+            None => None,
+        }
+    }
+
+    /// Return true if the command based on the given command name/alias exists
+    pub fn exists(&self, name: &str) -> bool {
+        let command = self.get(name);
+
+        command.is_some()
+    }
+
+    /// Return the command based on the given command name/alias.
+    /// It will also remove it in the process.
+    pub fn get_for_use(&mut self, name: &str) -> Option<Box<dyn Command>> {
+        let command_name = match self.aliases.get(name) {
+            Some(ref value) => value,
+            None => name,
+        };
+
+        match self.commands.remove(command_name) {
+            Some(value) => Some(value),
+            None => None,
+        }
+    }
+
+    /// Returns all the command names currently registered
+    pub fn get_all_command_names(&self) -> Vec<String> {
+        let mut names = vec![];
+
+        for key in self.commands.keys() {
+            names.push(key.to_string());
+        }
+
+        names.sort();
+
+        names
+    }
+
+    /// Removes the requested command.
+    pub fn remove(&mut self, name: &str) {
+        self.get_for_use(name);
+    }
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/types/error.rs.html b/docs/api/duckscript/src/duckscript/types/error.rs.html new file mode 100644 index 0000000..18ddd0f --- /dev/null +++ b/docs/api/duckscript/src/duckscript/types/error.rs.html @@ -0,0 +1,235 @@ +error.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+
+//! # error
+//!
+//! The error structure and types.
+//!
+
+use crate::types::instruction::InstructionMetaInfo;
+use std::fmt;
+use std::fmt::Display;
+use std::io;
+
+#[cfg(test)]
+#[path = "./error_test.rs"]
+mod error_test;
+
+fn format_error_message(
+    formatter: &mut fmt::Formatter,
+    meta_info: &InstructionMetaInfo,
+    message: &str,
+) -> Result<(), fmt::Error> {
+    let source = match meta_info.source {
+        Some(ref value) => value.to_string(),
+        None => "Unknown".to_string(),
+    };
+    let line = match meta_info.line {
+        Some(value) => value.to_string(),
+        None => "Unknown".to_string(),
+    };
+
+    write!(formatter, "Source: {} Line: {} - {}", source, line, message)
+}
+
+#[derive(Debug)]
+/// Holds the error information
+pub enum ErrorInfo {
+    /// Error Info Type
+    ErrorReadingFile(String, Option<io::Error>),
+    /// Error Info Type
+    Initialization(String),
+    /// Error Info Type
+    Runtime(String, Option<InstructionMetaInfo>),
+    /// Error Info Type
+    PreProcessNoCommandFound(InstructionMetaInfo),
+    /// Error Info Type
+    ControlWithoutValidValue(InstructionMetaInfo),
+    /// Error Info Type
+    InvalidControlLocation(InstructionMetaInfo),
+    /// Error Info Type
+    MissingEndQuotes(InstructionMetaInfo),
+    /// Error Info Type
+    MissingOutputVariableName(InstructionMetaInfo),
+    /// Error Info Type
+    InvalidEqualsLocation(InstructionMetaInfo),
+    /// Error Info Type
+    InvalidQuotesLocation(InstructionMetaInfo),
+    /// Error Info Type
+    EmptyLabel(InstructionMetaInfo),
+    /// Error Info Type
+    UnknownPreProcessorCommand(InstructionMetaInfo),
+}
+
+#[derive(Debug)]
+/// Script error struct
+pub struct ScriptError {
+    /// Holds the error information
+    pub info: ErrorInfo,
+}
+
+impl Display for ScriptError {
+    /// Formats the script error using the given formatter.
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+        match self.info {
+            ErrorInfo::ErrorReadingFile(ref file, ref cause) => {
+                writeln!(formatter, "Error reading file: {}", file)?;
+                match cause {
+                    Some(cause_err) => cause_err.fmt(formatter),
+                    None => Ok(()),
+                }
+            }
+            ErrorInfo::Initialization(ref message) => write!(formatter, "{}", message),
+            ErrorInfo::Runtime(ref message, ref meta_info) => {
+                let empty_meta_data = InstructionMetaInfo::new();
+                let meta_info_value = meta_info.as_ref().unwrap_or(&empty_meta_data);
+                format_error_message(formatter, &meta_info_value, message)
+            }
+            ErrorInfo::PreProcessNoCommandFound(ref meta_info) => {
+                format_error_message(formatter, &meta_info, "preprocessor is missing a command")
+            }
+            ErrorInfo::ControlWithoutValidValue(ref meta_info) => format_error_message(
+                formatter,
+                &meta_info,
+                "control character found without a valid value",
+            ),
+            ErrorInfo::InvalidControlLocation(ref meta_info) => {
+                format_error_message(formatter, &meta_info, "invalid control character location")
+            }
+            ErrorInfo::MissingEndQuotes(ref meta_info) => {
+                format_error_message(formatter, &meta_info, "missing end quotes")
+            }
+            ErrorInfo::MissingOutputVariableName(ref meta_info) => {
+                format_error_message(formatter, &meta_info, "missing variable name")
+            }
+            ErrorInfo::InvalidEqualsLocation(ref meta_info) => {
+                format_error_message(formatter, &meta_info, "invalid equals sign location")
+            }
+            ErrorInfo::InvalidQuotesLocation(ref meta_info) => {
+                format_error_message(formatter, &meta_info, "invalid quotes location")
+            }
+            ErrorInfo::EmptyLabel(ref meta_info) => {
+                format_error_message(formatter, &meta_info, "empty lable found")
+            }
+            ErrorInfo::UnknownPreProcessorCommand(ref meta_info) => {
+                format_error_message(formatter, &meta_info, "unknow preprocessor command")
+            }
+        }
+    }
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/types/instruction.rs.html b/docs/api/duckscript/src/duckscript/types/instruction.rs.html new file mode 100644 index 0000000..5d4d5d2 --- /dev/null +++ b/docs/api/duckscript/src/duckscript/types/instruction.rs.html @@ -0,0 +1,245 @@ +instruction.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+
+//! # instruction
+//!
+//! The instruction type.
+//!
+
+#[cfg(test)]
+#[path = "./instruction_test.rs"]
+mod instruction_test;
+
+trait InstructionOperations {
+    /// Returns true if this instruction has some actionable command to run
+    fn is_actionable(&self) -> bool;
+}
+
+/// Preprocess instruction
+#[derive(Debug, Clone)]
+pub struct PreProcessInstruction {
+    /// The command name
+    pub command: Option<String>,
+    /// The command arguments
+    pub arguments: Option<Vec<String>>,
+}
+
+impl PreProcessInstruction {
+    /// Creates and returns a new instance.
+    pub fn new() -> PreProcessInstruction {
+        PreProcessInstruction {
+            command: None,
+            arguments: None,
+        }
+    }
+}
+
+impl InstructionOperations for PreProcessInstruction {
+    /// Returns true if this instruction has some actionable command to run
+    fn is_actionable(&self) -> bool {
+        return self.command.is_some();
+    }
+}
+
+/// Runtime script instruction
+#[derive(Debug, Clone)]
+pub struct ScriptInstruction {
+    /// The label tag
+    pub label: Option<String>,
+    /// The command output variable name
+    pub output: Option<String>,
+    /// The command name
+    pub command: Option<String>,
+    /// The command arguments
+    pub arguments: Option<Vec<String>>,
+}
+
+impl ScriptInstruction {
+    /// Creates and returns a new instance.
+    pub fn new() -> ScriptInstruction {
+        ScriptInstruction {
+            label: None,
+            output: None,
+            command: None,
+            arguments: None,
+        }
+    }
+}
+
+impl InstructionOperations for ScriptInstruction {
+    /// Returns true if this instruction has some actionable command to run
+    fn is_actionable(&self) -> bool {
+        return self.command.is_some();
+    }
+}
+
+/// Instruction Type - script, preprocess
+#[derive(Debug, Clone)]
+pub enum InstructionType {
+    /// Empty instruction
+    Empty,
+    /// Preprocess instruction
+    PreProcess(PreProcessInstruction),
+    /// Runtime script instruction
+    Script(ScriptInstruction),
+}
+
+/// Meta information for all instruction types
+#[derive(Debug, Clone)]
+pub struct InstructionMetaInfo {
+    /// The line number
+    pub line: Option<usize>,
+    /// The source file/url/...
+    pub source: Option<String>,
+}
+
+impl InstructionMetaInfo {
+    /// Creates and returns a new instance.
+    pub fn new() -> InstructionMetaInfo {
+        InstructionMetaInfo {
+            line: None,
+            source: None,
+        }
+    }
+}
+
+/// Instruction data
+#[derive(Debug, Clone)]
+pub struct Instruction {
+    /// Meta info
+    pub meta_info: InstructionMetaInfo,
+    /// The instruction
+    pub instruction_type: InstructionType,
+}
+
+impl InstructionOperations for Instruction {
+    /// Returns true if this instruction has some actionable command to run
+    fn is_actionable(&self) -> bool {
+        match self.instruction_type {
+            InstructionType::Empty => false,
+            InstructionType::PreProcess(ref value) => value.is_actionable(),
+            InstructionType::Script(ref value) => value.is_actionable(),
+        }
+    }
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/types/mod.rs.html b/docs/api/duckscript/src/duckscript/types/mod.rs.html new file mode 100644 index 0000000..1950b46 --- /dev/null +++ b/docs/api/duckscript/src/duckscript/types/mod.rs.html @@ -0,0 +1,19 @@ +mod.rs.html -- source
1
+2
+3
+4
+5
+6
+7
+8
+
+//! # types
+//!
+//! All duckscript types.
+//!
+pub mod command;
+pub mod error;
+pub mod instruction;
+pub mod runtime;
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/src/duckscript/types/runtime.rs.html b/docs/api/duckscript/src/duckscript/types/runtime.rs.html new file mode 100644 index 0000000..90a2edf --- /dev/null +++ b/docs/api/duckscript/src/duckscript/types/runtime.rs.html @@ -0,0 +1,161 @@ +runtime.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+
+//! # runtime
+//!
+//! The runtime context structures.
+//!
+
+#[cfg(test)]
+#[path = "./runtime_test.rs"]
+mod runtime_test;
+
+use crate::types::command::Commands;
+use crate::types::instruction::Instruction;
+use std::collections::HashMap;
+
+/// enum defining what values can be stored in the state map
+#[derive(Debug, Clone)]
+pub enum StateValue {
+    /// boolean value
+    Boolean(bool),
+    /// signed number
+    Number(isize),
+    /// unsigned number
+    UnsignedNumber(usize),
+    /// signed number
+    Number32Bit(i32),
+    /// unsigned number
+    UnsignedNumber32Bit(u32),
+    /// signed number
+    Number64Bit(i64),
+    /// unsigned number
+    UnsignedNumber64Bit(u64),
+    /// textual value
+    String(String),
+    /// list
+    List(Vec<StateValue>),
+    /// sub state value
+    SubState(HashMap<String, StateValue>),
+}
+
+/// The context structure
+pub struct Context {
+    /// The runtime variables
+    pub variables: HashMap<String, String>,
+    /// The runtime state
+    pub state: HashMap<String, StateValue>,
+    /// The command implementations
+    pub commands: Commands,
+}
+
+impl Context {
+    /// Creates and returns a new instance.
+    pub fn new() -> Context {
+        Context {
+            variables: HashMap::new(),
+            state: HashMap::new(),
+            commands: Commands::new(),
+        }
+    }
+}
+
+/// The runtime structure
+pub struct Runtime {
+    /// The script instructions
+    pub instructions: Option<Vec<Instruction>>,
+    /// Label to line number mapping
+    pub label_to_line: HashMap<String, usize>,
+    /// The runtime context
+    pub context: Context,
+}
+
+impl Runtime {
+    /// Creates and returns a new instance.
+    pub fn new(context: Context) -> Runtime {
+        Runtime {
+            instructions: None,
+            label_to_line: HashMap::new(),
+            context,
+        }
+    }
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript/storage.js b/docs/api/duckscript/storage.js new file mode 100644 index 0000000..53b5c0f --- /dev/null +++ b/docs/api/duckscript/storage.js @@ -0,0 +1 @@ +var resourcesSuffix="";var currentTheme=document.getElementById("themeStyle");var mainTheme=document.getElementById("mainThemeStyle");var savedHref=[];function hasClass(elem,className){return elem&&elem.classList&&elem.classList.contains(className);}function addClass(elem,className){if(!elem||!elem.classList){return;}elem.classList.add(className);}function removeClass(elem,className){if(!elem||!elem.classList){return;}elem.classList.remove(className);}function isHidden(elem){return elem.offsetParent===null;}function onEach(arr,func,reversed){if(arr&&arr.length>0&&func){var length=arr.length;if(reversed!==true){for(var i=0;i=0;--i){if(func(arr[i])===true){return true;}}}}return false;}function onEachLazy(lazyArray,func,reversed){return onEach(Array.prototype.slice.call(lazyArray),func,reversed);}function usableLocalStorage(){if(typeof(Storage)==="undefined"){return false;}try{return window.localStorage!==null&&window.localStorage!==undefined;}catch(err){return false;}}function updateLocalStorage(name,value){if(usableLocalStorage()){localStorage[name]=value;}else{}}function getCurrentValue(name){if(usableLocalStorage()&&localStorage[name]!==undefined){return localStorage[name];}return null;}function switchTheme(styleElem,mainStyleElem,newTheme){var fullBasicCss="rustdoc"+resourcesSuffix+".css";var fullNewTheme=newTheme+resourcesSuffix+".css";var newHref=mainStyleElem.href.replace(fullBasicCss,fullNewTheme);if(styleElem.href===newHref){return;}var found=false;if(savedHref.length===0){onEachLazy(document.getElementsByTagName("link"),function(el){savedHref.push(el.href);});}onEach(savedHref,function(el){if(el===newHref){found=true;return true;}});if(found===true){styleElem.href=newHref;updateLocalStorage("rustdoc-theme",newTheme);}}switchTheme(currentTheme,mainTheme,getCurrentValue("rustdoc-theme")||"light"); \ No newline at end of file diff --git a/docs/api/duckscript/theme.js b/docs/api/duckscript/theme.js new file mode 100644 index 0000000..f3a6a82 --- /dev/null +++ b/docs/api/duckscript/theme.js @@ -0,0 +1,39 @@ +var themes = document.getElementById("theme-choices"); +var themePicker = document.getElementById("theme-picker"); + +function switchThemeButtonState() { + if (themes.style.display === "block") { + themes.style.display = "none"; + themePicker.style.borderBottomRightRadius = "3px"; + themePicker.style.borderBottomLeftRadius = "3px"; + } else { + themes.style.display = "block"; + themePicker.style.borderBottomRightRadius = "0"; + themePicker.style.borderBottomLeftRadius = "0"; + } +}; + +function handleThemeButtonsBlur(e) { + var active = document.activeElement; + var related = e.relatedTarget; + + if (active.id !== "themePicker" && + (!active.parentNode || active.parentNode.id !== "theme-choices") && + (!related || + (related.id !== "themePicker" && + (!related.parentNode || related.parentNode.id !== "theme-choices")))) { + switchThemeButtonState(); + } +} + +themePicker.onclick = switchThemeButtonState; +themePicker.onblur = handleThemeButtonsBlur; +["dark","light"].forEach(function(item) { + var but = document.createElement('button'); + but.innerHTML = item; + but.onclick = function(el) { + switchTheme(currentTheme, mainTheme, item); + }; + but.onblur = handleThemeButtonsBlur; + themes.appendChild(but); +}); \ No newline at end of file diff --git a/docs/api/duckscript/wheel.svg b/docs/api/duckscript/wheel.svg new file mode 100644 index 0000000..44381a4 --- /dev/null +++ b/docs/api/duckscript/wheel.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/api/duckscript_sdk/source-files.js b/docs/api/duckscript_sdk/source-files.js index 41c9a4f..4faa8fc 100644 --- a/docs/api/duckscript_sdk/source-files.js +++ b/docs/api/duckscript_sdk/source-files.js @@ -1,3 +1,3 @@ var N = null;var sourcesIndex = {}; -sourcesIndex["duckscriptsdk"] = {"name":"","dirs":[{"name":"sdk","dirs":[{"name":"internal","dirs":[{"name":"sdkdocs","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"std","dirs":[{"name":"alias","files":["mod.rs"]},{"name":"array","files":["mod.rs"]},{"name":"echo","files":["mod.rs"]},{"name":"env","dirs":[{"name":"cd","files":["mod.rs"]},{"name":"get","files":["mod.rs"]},{"name":"pwd","files":["mod.rs"]},{"name":"set","files":["mod.rs"]},{"name":"unset","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"eval","files":["mod.rs"]},{"name":"forin","files":["mod.rs"]},{"name":"fs","dirs":[{"name":"basename","files":["mod.rs"]},{"name":"canonical","files":["mod.rs"]},{"name":"cp","files":["mod.rs"]},{"name":"dirname","files":["mod.rs"]},{"name":"list","files":["mod.rs"]},{"name":"mkdir","files":["mod.rs"]},{"name":"mv","files":["mod.rs"]},{"name":"print","files":["mod.rs"]},{"name":"read","files":["mod.rs"]},{"name":"rm","files":["mod.rs"]},{"name":"rmdir","files":["mod.rs"]},{"name":"touch","files":["mod.rs"]},{"name":"write","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"function","files":["mod.rs"]},{"name":"goto","files":["mod.rs"]},{"name":"ifelse","files":["mod.rs"]},{"name":"man","files":["mod.rs"]},{"name":"math","dirs":[{"name":"calc","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"not","files":["mod.rs"]},{"name":"process","dirs":[{"name":"exec","files":["mod.rs"]},{"name":"exit","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"release","files":["mod.rs"]},{"name":"set","files":["mod.rs"]},{"name":"string","dirs":[{"name":"contains","files":["mod.rs"]},{"name":"ends_with","files":["mod.rs"]},{"name":"equals","files":["mod.rs"]},{"name":"starts_with","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"test","dirs":[{"name":"assert","files":["mod.rs"]},{"name":"assert_eq","files":["mod.rs"]},{"name":"assert_fail","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"thread","dirs":[{"name":"sleep","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"unalias","files":["mod.rs"]}],"files":["mod.rs"]}],"files":["mod.rs"]},{"name":"utils","files":["condition.rs","eval.rs","flags.rs","instruction_query.rs","io.rs","mod.rs","pckg.rs","state.rs"]}],"files":["lib.rs"]}; +sourcesIndex["duckscriptsdk"] = {"name":"","dirs":[{"name":"sdk","dirs":[{"name":"internal","dirs":[{"name":"sdkdocs","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"std","dirs":[{"name":"alias","files":["mod.rs"]},{"name":"collections","dirs":[{"name":"array","files":["mod.rs"]},{"name":"array_length","files":["mod.rs"]},{"name":"range","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"echo","files":["mod.rs"]},{"name":"env","dirs":[{"name":"cd","files":["mod.rs"]},{"name":"get","files":["mod.rs"]},{"name":"pwd","files":["mod.rs"]},{"name":"set","files":["mod.rs"]},{"name":"unset","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"eval","files":["mod.rs"]},{"name":"forin","files":["mod.rs"]},{"name":"fs","dirs":[{"name":"basename","files":["mod.rs"]},{"name":"canonical","files":["mod.rs"]},{"name":"cp","files":["mod.rs"]},{"name":"dirname","files":["mod.rs"]},{"name":"list","files":["mod.rs"]},{"name":"mkdir","files":["mod.rs"]},{"name":"mv","files":["mod.rs"]},{"name":"print","files":["mod.rs"]},{"name":"read","files":["mod.rs"]},{"name":"rm","files":["mod.rs"]},{"name":"rmdir","files":["mod.rs"]},{"name":"touch","files":["mod.rs"]},{"name":"write","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"function","files":["mod.rs"]},{"name":"goto","files":["mod.rs"]},{"name":"ifelse","files":["mod.rs"]},{"name":"is_defined","files":["mod.rs"]},{"name":"man","files":["mod.rs"]},{"name":"math","dirs":[{"name":"calc","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"net","dirs":[{"name":"hostname","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"not","files":["mod.rs"]},{"name":"on_error","dirs":[{"name":"get_last_error","files":["mod.rs"]},{"name":"get_last_error_line","files":["mod.rs"]},{"name":"get_last_error_source","files":["mod.rs"]},{"name":"on_error","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"os_family","files":["mod.rs"]},{"name":"process","dirs":[{"name":"exec","files":["mod.rs"]},{"name":"exit","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"read","files":["mod.rs"]},{"name":"release","files":["mod.rs"]},{"name":"set","files":["mod.rs"]},{"name":"string","dirs":[{"name":"contains","files":["mod.rs"]},{"name":"ends_with","files":["mod.rs"]},{"name":"equals","files":["mod.rs"]},{"name":"indexof","files":["mod.rs"]},{"name":"is_empty","files":["mod.rs"]},{"name":"last_indexof","files":["mod.rs"]},{"name":"length","files":["mod.rs"]},{"name":"starts_with","files":["mod.rs"]},{"name":"substring","files":["mod.rs"]},{"name":"trim","files":["mod.rs"]},{"name":"trim_end","files":["mod.rs"]},{"name":"trim_start","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"test","dirs":[{"name":"assert","files":["mod.rs"]},{"name":"assert_eq","files":["mod.rs"]},{"name":"assert_fail","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"thread","dirs":[{"name":"sleep","files":["mod.rs"]}],"files":["mod.rs"]},{"name":"unalias","files":["mod.rs"]}],"files":["mod.rs"]}],"files":["mod.rs"]},{"name":"utils","files":["condition.rs","eval.rs","flags.rs","instruction_query.rs","io.rs","mod.rs","pckg.rs","state.rs"]}],"files":["lib.rs"]}; createSourceSidebar(); diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/alias/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/alias/mod.rs.html index ae7f09f..04af101 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/alias/mod.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/alias/mod.rs.html @@ -228,7 +228,7 @@ match create_alias_command(name, arguments[1..].to_vec(), commands, sub_state) { Ok(_) => CommandResult::Continue(Some("true".to_string())), - Err(_) => CommandResult::Continue(Some("true".to_string())), + Err(error) => CommandResult::Error(error.to_string()), } } } diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/array/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/array/mod.rs.html similarity index 79% rename from docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/array/mod.rs.html rename to docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/array/mod.rs.html index bf169c7..b4ae11e 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/array/mod.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/array/mod.rs.html @@ -1,4 +1,4 @@ -mod.rs.html -- source
 1
+mod.rs.html -- source
 1
  2
  3
  4
@@ -118,4 +118,4 @@
     })
 }
 
-
\ No newline at end of file +
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/array_length/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/array_length/mod.rs.html new file mode 100644 index 0000000..a20b407 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/array_length/mod.rs.html @@ -0,0 +1,133 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+
+use crate::utils::pckg;
+use crate::utils::state::get_handles_sub_state;
+use duckscript::types::command::{Command, CommandResult, Commands};
+use duckscript::types::instruction::Instruction;
+use duckscript::types::runtime::StateValue;
+use std::collections::HashMap;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "ArrayLength")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["array_length".to_string(), "arrlen".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn requires_context(&self) -> bool {
+        true
+    }
+
+    fn run_with_context(
+        &self,
+        arguments: Vec<String>,
+        state: &mut HashMap<String, StateValue>,
+        _variables: &mut HashMap<String, String>,
+        _output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _line: usize,
+    ) -> CommandResult {
+        if arguments.is_empty() {
+            CommandResult::Error("Array handle not provided.".to_string())
+        } else {
+            let state = get_handles_sub_state(state);
+
+            let key = &arguments[0];
+
+            match state.get(key) {
+                Some(state_value) => match state_value {
+                    StateValue::List(list) => CommandResult::Continue(Some(list.len().to_string())),
+                    _ => CommandResult::Error("Invalid handle provided.".to_string()),
+                },
+                None => CommandResult::Error("Array not found.".to_string()),
+            }
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/mod.rs.html new file mode 100644 index 0000000..6a17641 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/mod.rs.html @@ -0,0 +1,41 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+
+pub(crate) mod array;
+mod array_length;
+mod range;
+
+use crate::utils::pckg;
+use duckscript::types::command::Commands;
+use duckscript::types::error::ScriptError;
+
+static PACKAGE: &str = "collections";
+
+pub(crate) fn load(commands: &mut Commands, parent: &str) -> Result<(), ScriptError> {
+    let package = pckg::concat(parent, PACKAGE);
+
+    commands.set(array::create(&package))?;
+    commands.set(array_length::create(&package))?;
+    commands.set(range::create(&package))?;
+
+    Ok(())
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/range/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/range/mod.rs.html new file mode 100644 index 0000000..7475dcf --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/collections/range/mod.rs.html @@ -0,0 +1,169 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+
+use crate::utils::pckg;
+use crate::utils::state::put_handle;
+use duckscript::types::command::{Command, CommandResult, Commands};
+use duckscript::types::instruction::Instruction;
+use duckscript::types::runtime::StateValue;
+use std::collections::HashMap;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "Range")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["range".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn requires_context(&self) -> bool {
+        true
+    }
+
+    fn run_with_context(
+        &self,
+        arguments: Vec<String>,
+        state: &mut HashMap<String, StateValue>,
+        _variables: &mut HashMap<String, String>,
+        _output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _line: usize,
+    ) -> CommandResult {
+        if arguments.len() < 2 {
+            CommandResult::Error("Invalid arguments provided.".to_string())
+        } else {
+            let start: i64 = match arguments[0].parse() {
+                Ok(value) => value,
+                Err(_) => {
+                    return CommandResult::Error(
+                        format!("Non numeric value: {} provided.", &arguments[0]).to_string(),
+                    );
+                }
+            };
+
+            let end: i64 = match arguments[1].parse() {
+                Ok(value) => value,
+                Err(_) => {
+                    return CommandResult::Error(
+                        format!("Non numeric value: {} provided.", &arguments[1]).to_string(),
+                    );
+                }
+            };
+
+            if start > end {
+                CommandResult::Error("Invalid arguments provided, range start value cannot be bigger than the range end value.".to_string())
+            } else {
+                let array: Vec<_> = (start..end)
+                    .map(|value| StateValue::Number64Bit(value))
+                    .collect();
+
+                let key = put_handle(state, StateValue::List(array));
+
+                CommandResult::Continue(Some(key))
+            }
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/forin/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/forin/mod.rs.html index 54b9ff6..3767f78 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/forin/mod.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/forin/mod.rs.html @@ -373,6 +373,9 @@ 373 374 375 +376 +377 +378
 use crate::utils::instruction_query;
 use crate::utils::pckg;
@@ -586,8 +589,16 @@
             StateValue::List(list) => {
                 if list.len() > iteration {
                     match list[iteration] {
-                        StateValue::String(ref string_value) => Some(string_value.to_string()),
-                        _ => None,
+                        StateValue::Boolean(ref value) => Some(value.to_string()),
+                        StateValue::Number(ref value) => Some(value.to_string()),
+                        StateValue::UnsignedNumber(ref value) => Some(value.to_string()),
+                        StateValue::Number32Bit(ref value) => Some(value.to_string()),
+                        StateValue::UnsignedNumber32Bit(ref value) => Some(value.to_string()),
+                        StateValue::Number64Bit(ref value) => Some(value.to_string()),
+                        StateValue::UnsignedNumber64Bit(ref value) => Some(value.to_string()),
+                        StateValue::String(ref value) => Some(value.to_string()),
+                        StateValue::List(_) => None,
+                        StateValue::SubState(_) => None,
                     }
                 } else {
                     None
@@ -648,7 +659,7 @@
                             iteration: 0,
                             meta_info: forin_meta_info,
                         },
-                        Err(error) => return CommandResult::Error(error.to_string()),
+                        Err(error) => return CommandResult::Crash(error.to_string()),
                     }
                 }
             };
@@ -656,25 +667,20 @@
             let iteration = call_info.iteration;
             let forin_meta_info = call_info.meta_info;
 
-            match variables.get(&arguments[2]) {
-                Some(handle) => match get_next_iteration(iteration, handle.to_string(), state) {
-                    Some(next_value) => {
-                        store_call_info(
-                            &CallInfo {
-                                iteration: iteration + 1,
-                                meta_info: forin_meta_info,
-                            },
-                            state,
-                        );
+            let handle = &arguments[2];
+            match get_next_iteration(iteration, handle.to_string(), state) {
+                Some(next_value) => {
+                    store_call_info(
+                        &CallInfo {
+                            iteration: iteration + 1,
+                            meta_info: forin_meta_info,
+                        },
+                        state,
+                    );
 
-                        variables.insert(arguments[0].clone(), next_value);
-                        CommandResult::Continue(None)
-                    }
-                    None => {
-                        let next_line = forin_meta_info.end + 1;
-                        CommandResult::GoTo(None, GoToValue::Line(next_line))
-                    }
-                },
+                    variables.insert(arguments[0].clone(), next_value);
+                    CommandResult::Continue(None)
+                }
                 None => {
                     let next_line = forin_meta_info.end + 1;
                     CommandResult::GoTo(None, GoToValue::Line(next_line))
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/cp/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/cp/mod.rs.html
index 5e1a4d0..a0de6b1 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/cp/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/cp/mod.rs.html
@@ -104,7 +104,7 @@
             let source_path_str = &arguments[0];
             let source_path = Path::new(source_path_str);
             if !source_path.exists() {
-                CommandResult::Continue(Some("false".to_string()))
+                CommandResult::Error("Path does not exist.".to_string())
             } else {
                 let source_file = source_path.is_file();
 
@@ -114,9 +114,9 @@
                     match io::create_parent_directory(target_path_str) {
                         Ok(_) => match fs::copy(source_path_str, target_path_str) {
                             Ok(_) => CommandResult::Continue(Some("true".to_string())),
-                            Err(_) => CommandResult::Continue(Some("false".to_string())),
+                            Err(error) => CommandResult::Error(error.to_string()),
                         },
-                        Err(_) => CommandResult::Continue(Some("false".to_string())),
+                        Err(error) => CommandResult::Error(error.to_string()),
                     }
                 } else {
                     match io::create_directory(target_path_str) {
@@ -125,10 +125,10 @@
 
                             match dir::copy(source_path_str, target_path_str, &options) {
                                 Ok(_) => CommandResult::Continue(Some("true".to_string())),
-                                Err(_) => CommandResult::Continue(Some("false".to_string())),
+                                Err(error) => CommandResult::Error(error.to_string()),
                             }
                         }
-                        Err(_) => CommandResult::Continue(Some("false".to_string())),
+                        Err(error) => CommandResult::Error(error.to_string()),
                     }
                 }
             }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/mkdir/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/mkdir/mod.rs.html
index 52e9fb9..afad54e 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/mkdir/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/mkdir/mod.rs.html
@@ -70,7 +70,7 @@
         } else {
             match io::create_directory(&arguments[0]) {
                 Ok(_) => CommandResult::Continue(Some("true".to_string())),
-                Err(_) => CommandResult::Continue(Some("false".to_string())),
+                Err(error) => CommandResult::Error(error.to_string()),
             }
         }
     }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/mv/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/mv/mod.rs.html
index c1eb3a3..dbb41e5 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/mv/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/mv/mod.rs.html
@@ -101,7 +101,7 @@
             let source_path = Path::new(&arguments[0]);
 
             if !source_path.exists() {
-                CommandResult::Continue(Some("false".to_string()))
+                CommandResult::Error("Path does not exist.".to_string())
             } else {
                 let target_path = Path::new(&arguments[1]);
                 let source_file = source_path.is_file();
@@ -110,7 +110,7 @@
                 if source_file && target_file {
                     match fs::rename(&arguments[0], &arguments[1]) {
                         Ok(_) => CommandResult::Continue(Some("true".to_string())),
-                        Err(_) => CommandResult::Continue(Some("false".to_string())),
+                        Err(error) => CommandResult::Error(error.to_string()),
                     }
                 } else {
                     match io::create_directory(&arguments[1]) {
@@ -119,10 +119,10 @@
                             let from_paths = vec![&arguments[0]];
                             match move_items(&from_paths, &arguments[1], &options) {
                                 Ok(_) => CommandResult::Continue(Some("true".to_string())),
-                                Err(_) => CommandResult::Continue(Some("false".to_string())),
+                                Err(error) => CommandResult::Error(error.to_string()),
                             }
                         }
-                        Err(_) => CommandResult::Continue(Some("false".to_string())),
+                        Err(error) => CommandResult::Error(error.to_string()),
                     }
                 }
             }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/print/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/print/mod.rs.html
index 1f9d8c2..a8b3ae4 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/print/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/print/mod.rs.html
@@ -82,7 +82,7 @@
 
                     CommandResult::Continue(Some(text))
                 }
-                Err(_) => CommandResult::Continue(None),
+                Err(error) => CommandResult::Error(error.to_string()),
             }
         }
     }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/read/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/read/mod.rs.html
index aadf5f2..b2754fa 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/read/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/read/mod.rs.html
@@ -74,7 +74,7 @@
 
             match result {
                 Ok(text) => CommandResult::Continue(Some(text)),
-                Err(_) => CommandResult::Continue(None),
+                Err(error) => CommandResult::Error(error.to_string()),
             }
         }
     }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/rm/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/rm/mod.rs.html
index b26babf..e058752 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/rm/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/fs/rm/mod.rs.html
@@ -120,7 +120,7 @@
 
             match result {
                 Ok(_) => CommandResult::Continue(Some("true".to_string())),
-                Err(_) => CommandResult::Continue(Some("false".to_string())),
+                Err(error) => CommandResult::Error(error.to_string()),
             }
         }
     }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/function/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/function/mod.rs.html
index dabe0cd..6d72187 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/function/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/function/mod.rs.html
@@ -809,11 +809,11 @@
                                     Err(error) => CommandResult::Error(error),
                                 }
                             }
-                            None => CommandResult::Error(
+                            None => CommandResult::Crash(
                                 format!("Function: {} end not found.", &function_name).to_string(),
                             ),
                         },
-                        Err(error) => CommandResult::Error(error),
+                        Err(error) => CommandResult::Crash(error),
                     }
                 }
             }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/ifelse/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/ifelse/mod.rs.html
index f2d186c..6291bed 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/ifelse/mod.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/ifelse/mod.rs.html
@@ -875,7 +875,7 @@
                         Err(error) => CommandResult::Error(error.to_string()),
                     }
                 }
-                Err(error) => CommandResult::Error(error.to_string()),
+                Err(error) => CommandResult::Crash(error.to_string()),
             }
         }
     }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/is_defined/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/is_defined/mod.rs.html
new file mode 100644
index 0000000..7282528
--- /dev/null
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/is_defined/mod.rs.html
@@ -0,0 +1,115 @@
+mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult, Commands};
+use duckscript::types::instruction::Instruction;
+use duckscript::types::runtime::StateValue;
+use std::collections::HashMap;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "IsDefined")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["is_defined".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn requires_context(&self) -> bool {
+        true
+    }
+
+    fn run_with_context(
+        &self,
+        arguments: Vec<String>,
+        _state: &mut HashMap<String, StateValue>,
+        variables: &mut HashMap<String, String>,
+        _output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _test_setline: usize,
+    ) -> CommandResult {
+        if arguments.is_empty() {
+            CommandResult::Error("Variable name not provided.".to_string())
+        } else {
+            let result = variables.contains_key(&arguments[0]);
+
+            CommandResult::Continue(Some(result.to_string()))
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/mod.rs.html index 74d1205..c438d00 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/mod.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/mod.rs.html @@ -49,9 +49,19 @@ 49 50 51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61
 pub(crate) mod alias;
-mod array;
+pub(crate) mod collections;
 mod echo;
 mod env;
 mod eval;
@@ -60,10 +70,15 @@
 mod function;
 mod goto;
 mod ifelse;
+mod is_defined;
 mod man;
 mod math;
+mod net;
 mod not;
+mod on_error;
+mod os_family;
 mod process;
+mod read;
 mod release;
 mod set;
 mod string;
@@ -74,26 +89,31 @@
 use duckscript::types::command::Commands;
 use duckscript::types::error::ScriptError;
 
-static PACKAGE: &str = "sdk";
+static PACKAGE: &str = "std";
 
 pub(crate) fn load(commands: &mut Commands) -> Result<(), ScriptError> {
     commands.set(alias::create(PACKAGE))?;
-    commands.set(array::create(PACKAGE))?;
     commands.set(echo::create(PACKAGE))?;
     commands.set(eval::create(PACKAGE))?;
     commands.set(goto::create(PACKAGE))?;
+    commands.set(is_defined::create(PACKAGE))?;
     commands.set(man::create(PACKAGE))?;
     commands.set(not::create(PACKAGE))?;
+    commands.set(os_family::create(PACKAGE))?;
+    commands.set(read::create(PACKAGE))?;
     commands.set(release::create(PACKAGE))?;
     commands.set(set::create(PACKAGE))?;
     commands.set(unalias::create(PACKAGE))?;
 
+    collections::load(commands, PACKAGE)?;
     env::load(commands, PACKAGE)?;
     forin::load(commands, PACKAGE)?;
     fs::load(commands, PACKAGE)?;
     function::load(commands, PACKAGE)?;
     ifelse::load(commands, PACKAGE)?;
     math::load(commands, PACKAGE)?;
+    net::load(commands, PACKAGE)?;
+    on_error::load(commands, PACKAGE)?;
     process::load(commands, PACKAGE)?;
     string::load(commands, PACKAGE)?;
     test::load(commands, PACKAGE)?;
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/net/hostname/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/net/hostname/mod.rs.html
new file mode 100644
index 0000000..486741e
--- /dev/null
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/net/hostname/mod.rs.html
@@ -0,0 +1,79 @@
+mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+use hostname;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "Hostname")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["hostname".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, _arguments: Vec<String>) -> CommandResult {
+        match hostname::get() {
+            Ok(value) => CommandResult::Continue(Some(value.to_string_lossy().into_owned())),
+            Err(_) => CommandResult::Continue(None),
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/net/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/net/mod.rs.html new file mode 100644 index 0000000..2a7ea18 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/net/mod.rs.html @@ -0,0 +1,33 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+
+mod hostname;
+
+use crate::utils::pckg;
+use duckscript::types::command::Commands;
+use duckscript::types::error::ScriptError;
+
+static PACKAGE: &str = "net";
+
+pub(crate) fn load(commands: &mut Commands, parent: &str) -> Result<(), ScriptError> {
+    let package = pckg::concat(parent, PACKAGE);
+
+    commands.set(hostname::create(&package))?;
+
+    Ok(())
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/get_last_error/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/get_last_error/mod.rs.html new file mode 100644 index 0000000..72ac35d --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/get_last_error/mod.rs.html @@ -0,0 +1,107 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+
+use crate::sdk::std::on_error::get_value;
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult, Commands};
+use duckscript::types::instruction::Instruction;
+use duckscript::types::runtime::StateValue;
+use std::collections::HashMap;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "GetLastError")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["get_last_error".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn requires_context(&self) -> bool {
+        true
+    }
+
+    fn run_with_context(
+        &self,
+        _arguments: Vec<String>,
+        state: &mut HashMap<String, StateValue>,
+        _variables: &mut HashMap<String, String>,
+        _output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _line: usize,
+    ) -> CommandResult {
+        let value = get_value(state, "error".to_string());
+        CommandResult::Continue(value)
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/get_last_error_line/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/get_last_error_line/mod.rs.html new file mode 100644 index 0000000..5925c90 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/get_last_error_line/mod.rs.html @@ -0,0 +1,107 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+
+use crate::sdk::std::on_error::get_value;
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult, Commands};
+use duckscript::types::instruction::Instruction;
+use duckscript::types::runtime::StateValue;
+use std::collections::HashMap;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "GetLastErrorLine")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["get_last_error_line".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn requires_context(&self) -> bool {
+        true
+    }
+
+    fn run_with_context(
+        &self,
+        _arguments: Vec<String>,
+        state: &mut HashMap<String, StateValue>,
+        _variables: &mut HashMap<String, String>,
+        _output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _line: usize,
+    ) -> CommandResult {
+        let value = get_value(state, "line".to_string());
+        CommandResult::Continue(value)
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/get_last_error_source/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/get_last_error_source/mod.rs.html new file mode 100644 index 0000000..85d331f --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/get_last_error_source/mod.rs.html @@ -0,0 +1,107 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+
+use crate::sdk::std::on_error::get_value;
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult, Commands};
+use duckscript::types::instruction::Instruction;
+use duckscript::types::runtime::StateValue;
+use std::collections::HashMap;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "GetLastErrorSource")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["get_last_error_source".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn requires_context(&self) -> bool {
+        true
+    }
+
+    fn run_with_context(
+        &self,
+        _arguments: Vec<String>,
+        state: &mut HashMap<String, StateValue>,
+        _variables: &mut HashMap<String, String>,
+        _output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _line: usize,
+    ) -> CommandResult {
+        let value = get_value(state, "source".to_string());
+        CommandResult::Continue(value)
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/mod.rs.html new file mode 100644 index 0000000..13cb6b4 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/mod.rs.html @@ -0,0 +1,77 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+
+mod get_last_error;
+mod get_last_error_line;
+mod get_last_error_source;
+mod on_error;
+
+use crate::utils::pckg;
+use crate::utils::state::get_core_sub_state_for_command;
+use duckscript::types::command::Commands;
+use duckscript::types::error::ScriptError;
+use duckscript::types::runtime::StateValue;
+use std::collections::HashMap;
+
+static PACKAGE: &str = "error";
+pub(crate) static STATE_KEY: &str = "on_error";
+
+pub(crate) fn get_value(state: &mut HashMap<String, StateValue>, key: String) -> Option<String> {
+    let sub_state = get_core_sub_state_for_command(state, STATE_KEY.to_string());
+
+    match sub_state.get(&key) {
+        Some(state_value) => match state_value {
+            StateValue::String(value) => Some(value.clone()),
+            _ => None,
+        },
+        None => None,
+    }
+}
+
+pub(crate) fn load(commands: &mut Commands, parent: &str) -> Result<(), ScriptError> {
+    let package = pckg::concat(parent, PACKAGE);
+
+    commands.set(get_last_error::create(&package))?;
+    commands.set(get_last_error_line::create(&package))?;
+    commands.set(get_last_error_source::create(&package))?;
+    commands.set(on_error::create(&package))?;
+
+    Ok(())
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/on_error/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/on_error/mod.rs.html new file mode 100644 index 0000000..6efe7e8 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/on_error/on_error/mod.rs.html @@ -0,0 +1,153 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+
+use crate::sdk::std::on_error;
+use crate::utils::pckg;
+use crate::utils::state::get_core_sub_state_for_command;
+use duckscript::types::command::{Command, CommandResult, Commands};
+use duckscript::types::instruction::Instruction;
+use duckscript::types::runtime::StateValue;
+use std::collections::HashMap;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "OnError")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["on_error".to_string()]
+    }
+
+    fn help(&self) -> String {
+        "".to_string()
+    }
+
+    fn requires_context(&self) -> bool {
+        true
+    }
+
+    fn run_with_context(
+        &self,
+        arguments: Vec<String>,
+        state: &mut HashMap<String, StateValue>,
+        _variables: &mut HashMap<String, String>,
+        _output_variable: Option<String>,
+        _instructions: &Vec<Instruction>,
+        _commands: &mut Commands,
+        _line: usize,
+    ) -> CommandResult {
+        if !arguments.is_empty() {
+            let error = arguments[0].clone();
+            let (line, source) = if arguments.len() > 1 {
+                let line = arguments[1].clone();
+                let source = if arguments.len() > 2 {
+                    arguments[2].clone()
+                } else {
+                    "".to_string()
+                };
+
+                (line, source)
+            } else {
+                ("".to_string(), "".to_string())
+            };
+
+            let sub_state = get_core_sub_state_for_command(state, on_error::STATE_KEY.to_string());
+            sub_state.insert("error".to_string(), StateValue::String(error));
+            sub_state.insert("line".to_string(), StateValue::String(line));
+            sub_state.insert("source".to_string(), StateValue::String(source));
+
+            CommandResult::Continue(Some("false".to_string()))
+        } else {
+            CommandResult::Crash("Invalid input provided.".to_string())
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/os_family/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/os_family/mod.rs.html new file mode 100644 index 0000000..677b179 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/os_family/mod.rs.html @@ -0,0 +1,87 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "GetOSFamily")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["os_family".to_string(), "uname".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, _arguments: Vec<String>) -> CommandResult {
+        let value = if cfg!(windows) {
+            "windows".to_string()
+        } else if cfg!(target_os = "macos") || cfg!(target_os = "ios") {
+            "mac".to_string()
+        } else {
+            "linux".to_string()
+        };
+
+        CommandResult::Continue(Some(value))
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/process/exit/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/process/exit/mod.rs.html index 7e7e4c7..5d5e556 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/process/exit/mod.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/process/exit/mod.rs.html @@ -59,7 +59,7 @@ } fn aliases(&self) -> Vec<String> { - vec!["exit".to_string()] + vec!["exit".to_string(), "quit".to_string(), "q".to_string()] } fn help(&self) -> String { diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/read/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/read/mod.rs.html new file mode 100644 index 0000000..8f29505 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/read/mod.rs.html @@ -0,0 +1,87 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+use std::io::stdin;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "ReadUserInput")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["read".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, _arguments: Vec<String>) -> CommandResult {
+        let mut text = String::new();
+
+        let value = match stdin().read_line(&mut text) {
+            Ok(_) => Some(text.trim().to_string()),
+            Err(_) => None,
+        };
+
+        CommandResult::Continue(value)
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/release/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/release/mod.rs.html index ddc40fd..0f18e62 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/release/mod.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/release/mod.rs.html @@ -58,6 +58,8 @@ 58 59 60 +61 +62
 use crate::utils::pckg;
 use crate::utils::state::get_handles_sub_state;
@@ -106,7 +108,9 @@
         } else {
             let state = get_handles_sub_state(state);
 
-            match state.remove(&arguments[0]) {
+            let key = &arguments[0];
+
+            match state.remove(key) {
                 Some(_) => CommandResult::Continue(Some("true".to_string())),
                 None => CommandResult::Continue(Some("false".to_string())),
             }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/indexof/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/indexof/mod.rs.html
new file mode 100644
index 0000000..923149c
--- /dev/null
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/indexof/mod.rs.html
@@ -0,0 +1,93 @@
+mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "IndexOf")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["indexof".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, arguments: Vec<String>) -> CommandResult {
+        if arguments.len() < 2 {
+            CommandResult::Error("Two arguments are required.".to_string())
+        } else {
+            let result = arguments[0].find(&arguments[1]);
+
+            let result_string = match result {
+                Some(value) => Some(value.to_string()),
+                None => None,
+            };
+
+            CommandResult::Continue(result_string)
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/is_empty/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/is_empty/mod.rs.html new file mode 100644 index 0000000..fb34f20 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/is_empty/mod.rs.html @@ -0,0 +1,81 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "IsEmpty")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["is_empty".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, arguments: Vec<String>) -> CommandResult {
+        if arguments.is_empty() {
+            CommandResult::Continue(Some("true".to_string()))
+        } else {
+            let result = arguments[0].is_empty();
+            CommandResult::Continue(Some(result.to_string()))
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/last_indexof/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/last_indexof/mod.rs.html new file mode 100644 index 0000000..a09794c --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/last_indexof/mod.rs.html @@ -0,0 +1,93 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "LastIndexOf")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["last_indexof".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, arguments: Vec<String>) -> CommandResult {
+        if arguments.len() < 2 {
+            CommandResult::Error("Two arguments are required.".to_string())
+        } else {
+            let result = arguments[0].rfind(&arguments[1]);
+
+            let result_string = match result {
+                Some(value) => Some(value.to_string()),
+                None => None,
+            };
+
+            CommandResult::Continue(result_string)
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/length/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/length/mod.rs.html new file mode 100644 index 0000000..88a366f --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/length/mod.rs.html @@ -0,0 +1,83 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "Length")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["length".to_string(), "strlen".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, arguments: Vec<String>) -> CommandResult {
+        if arguments.is_empty() {
+            CommandResult::Error("No argument provided.".to_string())
+        } else {
+            let string_len = arguments[0].len();
+
+            CommandResult::Continue(Some(string_len.to_string()))
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/mod.rs.html index 0d977b3..007394b 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/mod.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/mod.rs.html @@ -19,11 +19,35 @@ 19 20 21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37
 mod contains;
 mod ends_with;
 mod equals;
+mod indexof;
+mod is_empty;
+mod last_indexof;
+mod length;
 mod starts_with;
+mod substring;
+mod trim;
+mod trim_end;
+mod trim_start;
 
 use crate::utils::pckg;
 use duckscript::types::command::Commands;
@@ -37,7 +61,15 @@
     commands.set(contains::create(&package))?;
     commands.set(ends_with::create(&package))?;
     commands.set(equals::create(&package))?;
+    commands.set(indexof::create(&package))?;
+    commands.set(is_empty::create(&package))?;
+    commands.set(last_indexof::create(&package))?;
+    commands.set(length::create(&package))?;
     commands.set(starts_with::create(&package))?;
+    commands.set(substring::create(&package))?;
+    commands.set(trim::create(&package))?;
+    commands.set(trim_start::create(&package))?;
+    commands.set(trim_end::create(&package))?;
 
     Ok(())
 }
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/substring/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/substring/mod.rs.html
new file mode 100644
index 0000000..85b4188
--- /dev/null
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/substring/mod.rs.html
@@ -0,0 +1,239 @@
+mod.rs.html -- source
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+use std::convert::TryInto;
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+fn parse_number(string_value: &str) -> Result<isize, String> {
+    match string_value.parse() {
+        Ok(value) => Ok(value),
+        Err(_) => Err(format!("Non numeric value: {} provided.", string_value).to_string()),
+    }
+}
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "SubString")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["substring".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, arguments: Vec<String>) -> CommandResult {
+        if arguments.is_empty() {
+            CommandResult::Error("No arguments provided.".to_string())
+        } else {
+            let string_value = arguments[0].clone();
+            let string_len = string_value.len() as isize;
+
+            let (start, end) = if arguments.len() == 1 {
+                (0, string_len)
+            } else if arguments.len() == 2 {
+                match parse_number(&arguments[1]) {
+                    Ok(value) => {
+                        if value >= 0 {
+                            if value > (string_len - 1) {
+                                return CommandResult::Error(
+                                    "Start index cannot be bigger than total text size."
+                                        .to_string(),
+                                );
+                            } else {
+                                (value, string_len)
+                            }
+                        } else {
+                            let end_index = value + string_len;
+
+                            if end_index < 0 {
+                                return CommandResult::Error(
+                                    "Index from end cannot be bigger than total text size."
+                                        .to_string(),
+                                );
+                            } else {
+                                (0, end_index)
+                            }
+                        }
+                    }
+                    Err(error) => return CommandResult::Error(error.to_string()),
+                }
+            } else {
+                let start = match parse_number(&arguments[1]) {
+                    Ok(value) => {
+                        if value > (string_len - 1) {
+                            return CommandResult::Error(
+                                "Start index cannot be bigger than total text size.".to_string(),
+                            );
+                        } else {
+                            value
+                        }
+                    }
+                    Err(error) => return CommandResult::Error(error.to_string()),
+                };
+                let end = match parse_number(&arguments[2]) {
+                    Ok(value) => {
+                        if value >= start {
+                            if value > (string_len - 1) {
+                                return CommandResult::Error(
+                                    "End index cannot be bigger than total text size.".to_string(),
+                                );
+                            } else {
+                                value
+                            }
+                        } else {
+                            return CommandResult::Error(
+                                "End index cannot be smaller than start index.".to_string(),
+                            );
+                        }
+                    }
+                    Err(error) => return CommandResult::Error(error.to_string()),
+                };
+
+                (start, end)
+            };
+
+            let start_index: usize = start.try_into().unwrap();
+            let end_index: usize = end.try_into().unwrap();
+
+            let sub_string = &string_value.as_str()[start_index..end_index];
+
+            CommandResult::Continue(Some(sub_string.to_string()))
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/trim/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/trim/mod.rs.html new file mode 100644 index 0000000..2fdea64 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/trim/mod.rs.html @@ -0,0 +1,81 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "Trim")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["trim".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, arguments: Vec<String>) -> CommandResult {
+        if arguments.is_empty() {
+            CommandResult::Continue(None)
+        } else {
+            let result = arguments[0].trim();
+            CommandResult::Continue(Some(result.to_string()))
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/trim_end/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/trim_end/mod.rs.html new file mode 100644 index 0000000..71c2cb2 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/trim_end/mod.rs.html @@ -0,0 +1,81 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "TrimEnd")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["trim_end".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, arguments: Vec<String>) -> CommandResult {
+        if arguments.is_empty() {
+            CommandResult::Continue(None)
+        } else {
+            let result = arguments[0].trim_end();
+            CommandResult::Continue(Some(result.to_string()))
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/trim_start/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/trim_start/mod.rs.html new file mode 100644 index 0000000..4205422 --- /dev/null +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/string/trim_start/mod.rs.html @@ -0,0 +1,81 @@ +mod.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+
+use crate::utils::pckg;
+use duckscript::types::command::{Command, CommandResult};
+
+#[cfg(test)]
+#[path = "./mod_test.rs"]
+mod mod_test;
+
+struct CommandImpl {
+    package: String,
+}
+
+impl Command for CommandImpl {
+    fn name(&self) -> String {
+        pckg::concat(&self.package, "TrimStart")
+    }
+
+    fn aliases(&self) -> Vec<String> {
+        vec!["trim_start".to_string()]
+    }
+
+    fn help(&self) -> String {
+        include_str!("help.md").to_string()
+    }
+
+    fn run(&self, arguments: Vec<String>) -> CommandResult {
+        if arguments.is_empty() {
+            CommandResult::Continue(None)
+        } else {
+            let result = arguments[0].trim_start();
+            CommandResult::Continue(Some(result.to_string()))
+        }
+    }
+}
+
+pub(crate) fn create(package: &str) -> Box<dyn Command> {
+    Box::new(CommandImpl {
+        package: package.to_string(),
+    })
+}
+
+
\ No newline at end of file diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/thread/sleep/mod.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/thread/sleep/mod.rs.html index 07d738b..e002c53 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/thread/sleep/mod.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/sdk/std/thread/sleep/mod.rs.html @@ -101,7 +101,7 @@ } } Err(_) => CommandResult::Error( - format!("Non numberic value: {} provided.", &arguments[0]).to_string(), + format!("Non numeric value: {} provided.", &arguments[0]).to_string(), ), } } diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/utils/eval.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/utils/eval.rs.html index d8636f5..977ed86 100644 --- a/docs/api/duckscript_sdk/src/duckscriptsdk/utils/eval.rs.html +++ b/docs/api/duckscript_sdk/src/duckscriptsdk/utils/eval.rs.html @@ -46,6 +46,8 @@ 46 47 48 +49 +50
 use duckscript::parser;
 use duckscript::runner;
@@ -78,7 +80,9 @@
             line_buffer.push(' ');
         }
 
-        match parser::parse_text(&line_buffer) {
+        let line_str = line_buffer.replace("\r", "").replace("\n", "");
+
+        match parser::parse_text(&line_str) {
             Ok(instructions) => {
                 let (command_result, _) = runner::run_instruction(
                     commands,
diff --git a/docs/api/duckscript_sdk/src/duckscriptsdk/utils/state.rs.html b/docs/api/duckscript_sdk/src/duckscriptsdk/utils/state.rs.html
index 6878bcb..5cbf3c6 100644
--- a/docs/api/duckscript_sdk/src/duckscriptsdk/utils/state.rs.html
+++ b/docs/api/duckscript_sdk/src/duckscriptsdk/utils/state.rs.html
@@ -136,7 +136,7 @@
     state: &mut HashMap<String, StateValue>,
     name: String,
 ) -> &mut HashMap<String, StateValue> {
-    let sub_state_name = pckg::concat("duckscript", &name);
+    let sub_state_name = pckg::concat("duckscriptsdk", &name);
 
     get_sub_state(sub_state_name, state)
 }