]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
no bug - add some perl vscode snippets
authorDylan William Hardison <dylan@hardison.net>
Sat, 9 Mar 2019 01:06:51 +0000 (20:06 -0500)
committerGitHub <noreply@github.com>
Sat, 9 Mar 2019 01:06:51 +0000 (20:06 -0500)
.vscode/bmo.code-snippets [new file with mode: 0644]

diff --git a/.vscode/bmo.code-snippets b/.vscode/bmo.code-snippets
new file mode 100644 (file)
index 0000000..c0f8fee
--- /dev/null
@@ -0,0 +1,192 @@
+{
+  "Moo Package": {
+    "scope": "perl",
+    "prefix": "package-moo",
+    "body": [
+      "# This Source Code Form is subject to the terms of the Mozilla Public",
+      "# License, v. 2.0. If a copy of the MPL was not distributed with this",
+      "# file, You can obtain one at http://mozilla.org/MPL/2.0/.",
+      "#",
+      "# This Source Code Form is \"Incompatible With Secondary Licenses\", as",
+      "# defined by the Mozilla Public License, v. 2.0.\n",
+      "package ${1:${TM_FILENAME_BASE}};",
+      "use 5.10.1;",
+      "use Moo;\n",
+      "",
+      "${2}",
+      "",
+      "1;"
+    ],
+  },
+  "Mojo Command": {
+    "scope": "perl",
+    "prefix": "package-command",
+    "body": [
+      "# This Source Code Form is subject to the terms of the Mozilla Public",
+      "# License, v. 2.0. If a copy of the MPL was not distributed with this",
+      "# file, You can obtain one at http://mozilla.org/MPL/2.0/.",
+      "#",
+      "# This Source Code Form is \"Incompatible With Secondary Licenses\", as",
+      "# defined by the Mozilla Public License, v. 2.0.",
+      "",
+      "package Bugzilla::App::Command::${TM_FILENAME_BASE};   ## no critic (Capitalization)",
+      "use Mojo::Base 'Mojolicious::Command';",
+      "",
+      "use Bugzilla::Constants;",
+      "use Bugzilla::Logging;",
+      "use Mojo::Util 'getopt';",
+      "",
+      "has description => '${1}';",
+      "has usage       => sub { shift->extract_usage };",
+      "",
+      "sub run {",
+        "  my (\\$self, @args) = @_;",
+        "  my \\$option = 'default';",
+        "  my \\$required;",
+        "",
+        "  Bugzilla->usage_mode(USAGE_MODE_CMDLINE);",
+        "  getopt \\@args,",
+        "    'option|o=s'    => \\\\\\$option,",
+        "    'required|r=s'  => \\\\\\$required;",
+        "",
+        "  die \\$self->usage unless \\$required;",
+        "",
+        "$0",
+        "",
+        "}",
+        "",
+        "1;",
+        "",
+        "__END__",
+        "",
+        "=head1 NAME",
+        "",
+        "Bugzilla::App::Command::${TM_FILENAME_BASE} - $1",
+        "",
+        "=head1 SYNOPSIS",
+        "",
+        "  Usage: APPLICATION ${TM_FILENAME_BASE}",
+        "",
+        "    ./bugzilla.pl ${TM_FILENAME_BASE} --option=foo --required=bar",
+        "",
+        "  Options:",
+        "    -h, --help               Print a brief help message and exits.",
+        "    -o, --option value       Some option that has default.",
+        "    -r, --required str       Some required option.",
+        "",
+        "=head1 DESCRIPTION",
+        "",
+        "$2",
+        "",
+        "=head1 ATTRIBUTES",
+        "",
+        "L<Bugzilla::App::Command::${TM_FILENAME_BASE}> inherits all attributes from",
+        "L<Mojolicious::Command> and implements the following new ones.",
+        "",
+        "=head2 description",
+        "",
+        "  my \\$description = \\$${TM_FILENAME_BASE}->description;",
+        "  \\$${TM_FILENAME_BASE}        = \\$${TM_FILENAME_BASE}->description('Foo');",
+        "",
+        "Short description of this command, used for the command list.",
+        "",
+        "=head2 usage",
+        "",
+        "  my \\$usage = \\$${TM_FILENAME_BASE}->usage;",
+        "  \\$${TM_FILENAME_BASE}  = \\$${TM_FILENAME_BASE}->usage('Foo');",
+        "",
+        "Usage information for this command, used for the help screen.",
+        "",
+        "=head1 METHODS",
+        "",
+        "L<Bugzilla::App::Command::${TM_FILENAME_BASE}> inherits all methods from",
+        "L<Mojolicious::Command> and implements the following new ones.",
+        "",
+        "=head2 run",
+        "",
+        "  \\$${TM_FILENAME_BASE}->run(@ARGV);",
+        "",
+        "Run this command.",
+      ]
+    },
+    "Mojo Controller": {
+      "scope": "perl",
+      "prefix": "package-controller",
+      "body": [
+        "# This Source Code Form is subject to the terms of the Mozilla Public",
+        "# License, v. 2.0. If a copy of the MPL was not distributed with this",
+        "# file, You can obtain one at http://mozilla.org/MPL/2.0/.",
+        "#",
+        "# This Source Code Form is \"Incompatible With Secondary Licenses\", as",
+        "# defined by the Mozilla Public License, v. 2.0.\n",
+        "package Bugzilla::App::${TM_FILENAME_BASE};",
+        "use Mojo::Base qw( Mojolicious::Controller );\n",
+        "use Bugzilla::Logging;",
+        "",
+        "sub setup_routes {",
+          "  my (\\$class, \\$r) = @_;",
+          "  \\$r->get('/$1')->to('${TM_FILENAME_BASE}#$1');",
+          "}",
+          "",
+          "sub ${1} {",
+            "  my (\\$self) = @_;",
+            "  $0",
+            "}",
+            "",
+            "1;"
+          ]
+        },
+        "DBIC Result": {
+          "scope": "perl",
+          "description": "DBIx::Class Result",
+          "prefix": "package-dbic",
+          "body": [
+            "# This Source Code Form is subject to the terms of the Mozilla Public",
+            "# License, v. 2.0. If a copy of the MPL was not distributed with this",
+            "# file, You can obtain one at http://mozilla.org/MPL/2.0/.",
+            "#",
+            "# This Source Code Form is \"Incompatible With Secondary Licenses\", as",
+            "# defined by the Mozilla Public License, v. 2.0.\n",
+            "package Bugzilla::Model::Result::${TM_FILENAME_BASE};",
+            "use Mojo::Base 'DBIx::Class::Core';",
+            "",
+            "__PACKAGE__->table('${1:${TM_FILENAME_BASE:/downcase}}');",
+            "__PACKAGE__->set_primary_key('${2:id}');",
+            "__PACKAGE__->add_columns(qw[ ${3:columns} ]);",
+            "",
+            "$0",
+            "",
+            "1;"
+          ],
+        },
+        "License Header": {
+          "scope": "perl",
+          "prefix": "mpl",
+          "body": [
+            "# This Source Code Form is subject to the terms of the Mozilla Public",
+            "# License, v. 2.0. If a copy of the MPL was not distributed with this",
+            "# file, You can obtain one at http://mozilla.org/MPL/2.0/.",
+            "#",
+            "# This Source Code Form is \"Incompatible With Secondary Licenses\", as",
+            "# defined by the Mozilla Public License, v. 2.0.\n",
+            "",
+            "$0"
+          ]
+        },
+        "Script Header": {
+          "scope": "perl",
+          "prefix": "script",
+          "body": [
+            "#!/usr/bin/env perl",
+            "# This Source Code Form is subject to the terms of the Mozilla Public",
+            "# License, v. 2.0. If a copy of the MPL was not distributed with this",
+            "# file, You can obtain one at http://mozilla.org/MPL/2.0/.",
+            "#",
+            "# This Source Code Form is \"Incompatible With Secondary Licenses\", as",
+            "# defined by the Mozilla Public License, v. 2.0.\n",
+            "use Mojo::Base -strict;",
+            "",
+            "$0"
+          ]
+        }
+      }