]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
better defaults for re.pl
authorDylan William Hardison <dylan@hardison.net>
Fri, 21 Jul 2017 19:03:16 +0000 (15:03 -0400)
committerGitHub <noreply@github.com>
Fri, 21 Jul 2017 19:03:16 +0000 (15:03 -0400)
README.rst
vagrant_support/devtools.yml
vagrant_support/repl.rc [new file with mode: 0644]

index c1f3f8bfe63eddf6c29c382a3a41212b5e65b013..5db4c995452c74837a44e18c6f89f20f0bec3056 100644 (file)
@@ -10,6 +10,7 @@ BMO is Mozilla's highly customized version of Bugzilla.
       1.1  Setup Vagrant VMs
       1.2  Making Changes and Seeing them
       1.3  Technical Details
+      1.4  Perl Shell (re.pl, repl)
     2  Docker Container
       2.1  Container Arguments
       2.2  Environmental Variables
@@ -95,6 +96,55 @@ configured to use memcached.
 The push connector is not currently configured, nor is the Pulse publisher.
 
 
+Perl Shell (re.pl, repl)
+------------------------
+
+Installed on the vagrant vm is also a program called re.pl.
+
+re.pl an interactive perl shell (somtimes called a REPL (short for Read-Eval-Print-Loop)).
+It loads Bugzilla.pm and you can call Bugzilla internal API methods from it, an example session is reproduced below:
+
+.. code-block:: plain
+
+   re.pl
+   $ my $product = Bugzilla::Product->new({name => "Firefox"});
+   Took 0.0262260437011719 seconds.
+
+   $Bugzilla_Product1 = Bugzilla::Product=HASH(0x7e3c950);
+
+   $ $product->name
+   Took 0.000483036041259766 seconds.
+
+   Firefox
+
+It supports tab completion for file names, method names and so on. For more information see `Devel::REPL`_.
+
+You can use the 'p' command (provided by `Data::Printer`_) to inspect variables as well.
+
+.. code-block:: plain
+
+  $ p @INC
+  [
+      [0]  ".",
+      [1]  "lib",
+      [2]  "local/lib/perl5/x86_64-linux-thread-multi",
+      [3]  "local/lib/perl5",
+      [4]  "/home/vagrant/perl/lib/perl5/x86_64-linux-thread-multi",
+      [5]  "/home/vagrant/perl/lib/perl5",
+      [6]  "/vagrant/local/lib/perl5/x86_64-linux-thread-multi",
+      [7]  "/vagrant/local/lib/perl5",
+      [8]  "/usr/local/lib64/perl5",
+      [9]  "/usr/local/share/perl5",
+      [10] "/usr/lib64/perl5/vendor_perl",
+      [11] "/usr/share/perl5/vendor_perl",
+      [12] "/usr/lib64/perl5",
+      [13] "/usr/share/perl5",
+      [14] sub { ... }
+  ]
+
+.. _`Devel::REPL`: https://metacpan.org/pod/Devel::REPL
+.. _`Data::Printer`: https://metacpan.org/pod/Data::Printer
+
 Docker Container
 ================
 
index f9fb3e94fe1bb59e5a7cab4c5a887be95d8e3a36..fa554ce3ce1745a97c6294c1dc3ae42e404d6947 100644 (file)
@@ -9,7 +9,18 @@
 - cpanm: name=File::Next notest=true locallib=/home/vagrant/perl executable=/usr/local/bin/cpanm
 - cpanm: name=Sys::SigAction notest=true locallib=/home/vagrant/perl executable=/usr/local/bin/cpanm
 - cpanm: name=Lexical::Persistence notest=true locallib=/home/vagrant/perl executable=/usr/local/bin/cpanm
+- cpanm: name=Data::Printer notest=true locallib=/home/vagrant/perl executable=/usr/local/bin/cpanm
+- cpanm: name=Devel::REPL::Plugin::ReadLineHistory::WithoutExpansion notest=true locallib=/home/vagrant/perl executable=/usr/local/bin/cpanm
+
+- name: fix ownership of repl stuff
+  file: path=/home/vagrant/perl owner=vagrant group=vagrant recurse=true
 
 - name: copy re.pl
   copy: src=re.pl dest=/usr/local/bin/re.pl mode=0755
 
+- name: mkdir .re.pl
+  file: path=/home/vagrant/.re.pl state=directory owner=vagrant group=vagrant mode=0775
+
+- name: copy .re.pl/repl.rc
+  copy: src=repl.rc dest=/home/vagrant/.re.pl/repl.rc mode=0644
+
diff --git a/vagrant_support/repl.rc b/vagrant_support/repl.rc
new file mode 100644 (file)
index 0000000..89ad089
--- /dev/null
@@ -0,0 +1,28 @@
+#!perl
+# vim: set ft=perl:
+use Bugzilla;
+use Bugzilla::Constants;
+Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
+Bugzilla->extensions;
+use DDP return_value => 'void', colored => 1;
+
+my @plugins = qw(
+    Colors
+    Timing
+    Completion
+    CompletionDriver::INC
+    CompletionDriver::LexEnv
+    CompletionDriver::Keywords
+    CompletionDriver::Methods
+    History
+    LexEnv
+    DDS
+    Packages
+    Commands
+    MultiLine::PPI
+    ReadLineHistory::WithoutExpansion
+    Peek
+);
+
+$_REPL->load_plugin($_) for @plugins;
+