coveralls: 
[![Coverage Status](https://coveralls.io/builds/8409367/badge)](https://coveralls.io/builds/8409367)

Coverage increased (+1.4%) to 83.721% when pulling **df0ac543dc33b5ad23fb4dd94e5f512793a1f5f0 on import** into **0977f3585147190adec127722e940783209b6ab6 on master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/8409381/badge)](https://coveralls.io/builds/8409381)

Coverage increased (+1.4%) to 83.721% when pulling **df0ac543dc33b5ad23fb4dd94e5f512793a1f5f0 on import** into **0977f3585147190adec127722e940783209b6ab6 on master**.

diff --git a/jqp/__init__.py b/jqp/__init__.py
index cdcc02e..90fd8de 100644
--- a/jqp/__init__.py
+++ b/jqp/__init__.py
@@ -14,7 +14,15 @@ def _exit(error, return_code, message):
     sys.exit(return_code)
 
 
-def run(in_io, out_io, cmd):
+def run(in_io, out_io, cmd, imports=[]):
+    environment = {}
+    for mod_name in imports:
+        try:
+            mod = __import__(mod_name)
+        except Exception as e:
+            _exit(e, 5, 'Cannot import module: %s' % mod_name)
+        environment[mod_name] = mod
+
     for i, line in enumerate(in_io):
         if line.strip() == '':
             continue
@@ -26,7 +34,8 @@ def run(in_io, out_io, cmd):
             _exit(e, 4, 'Parse error: line %d' % line_no)
 
         try:
-            out = eval(cmd, {'j': js})
+            environment['j'] = js
+            out = eval(cmd, environment)
         except Exception as e:
             _exit(e, 3, 'Cannot execute command: line %d' % line_no)
 
@@ -44,6 +53,10 @@ def main():
     parser.add_argument(
         '--version', action='version', version='jqp %s' % __version__,
         help='show version and exit')
+    parser.add_argument(
+        '--import', action='append',
+        help='modules to import')
+
     args = parser.parse_args()
 
-    run(sys.stdin, sys.stdout, args.cmd)
+    run(sys.stdin, sys.stdout, args.cmd, imports=getattr(args, 'import'))

Make import option
I need an option to import modules which I use in commands.
diff --git a/tests/run_test.py b/tests/run_test.py
index 31ceb87..8e64641 100644
--- a/tests/run_test.py
+++ b/tests/run_test.py
@@ -16,6 +16,13 @@ class RunTest(unittest.TestCase):
         jqp.run(inputs, outputs, 'j["name"]')
         self.assertEqual(outputs.getvalue(), '"Taro"\n')
 
+    def test_import(self):
+        inputs = StringIO('''{"name": "Taro", "age": 10}
+''')
+        outputs = StringIO()
+        jqp.run(inputs, outputs, 're.sub("a", "A", j["name"])', imports=['re'])
+        self.assertEqual(outputs.getvalue(), '"TAro"\n')
+
     def test_parse_error(self):
         inputs = StringIO('invalid\n')
         outputs = StringIO()
@@ -36,3 +43,10 @@ class RunTest(unittest.TestCase):
         with self.assertRaises(SystemExit) as e:
             jqp.run(inputs, outputs, 'lambda: 0')
         self.assertEqual(e.exception.code, 3)
+
+    def test_import_error(self):
+        inputs = StringIO('1\n')
+        outputs = StringIO()
+        with self.assertRaises(SystemExit) as e:
+            jqp.run(inputs, outputs, 'j', imports=['unknown_module'])
+        self.assertEqual(e.exception.code, 5)

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov
apt-get update apt-get install -y gcc
3.5
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
coverage==6.2
importlib-metadata==4.8.3
iniconfig==1.1.1
-e git+https://github.com/unnonouno/jqp.git@0977f3585147190adec127722e940783209b6ab6#egg=jqp
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cov==4.0.0
tomli==1.2.3
typing_extensions==4.1.1
zipp==3.6.0

name: jqp
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - coverage==6.2
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - zipp==3.6.0
prefix: /opt/conda/envs/jqp

tests/run_test.py::RunTest::test_import tests/run_test.py::RunTest::test_import_error
tests/run_test.py::RunTest::test1 tests/run_test.py::RunTest::test_dump_error tests/run_test.py::RunTest::test_execution_error tests/run_test.py::RunTest::test_parse_error
jqp/__init__.py
jqp/__init__.py