Skip to content

Instantly share code, notes, and snippets.

@teh
Last active August 24, 2016 14:10
Show Gist options
  • Save teh/5c8de9eb7eb8b763730f37be75f88562 to your computer and use it in GitHub Desktop.
Save teh/5c8de9eb7eb8b763730f37be75f88562 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""
Welcome to Tom-does-another-disgusting-hack.
This is an executable shim for the stack binary whose only purpose is
to make the amazing intero mode [1] work in a non-stack environment (Nix
in our case).
Dump it somewhere and make sure it runs *instead* of the actual stack binary.
You will not be able to use stack at the same time.
[1]
https://github.com/commercialhaskell/intero
"""
import sys
import time
import os
import subprocess
def log(l):
subprocess.call(["logger", repr(l)])
def main():
if sys.argv[1:] == ["path", "--project-root", "--verbosity", "silent"]:
print os.getcwd()
return
if sys.argv[1:] == ["exec", '--verbosity', 'silent', '--', 'intero', '--version']:
print "0.1.17"
return
if sys.argv[1:3] == ["exec", "intero"]:
subprocess.call(["intero"])
return
if sys.argv[1:4] == ['ghci', '--with-ghc', 'intero']:
odir = sys.argv[8]
hidir = sys.argv[10]
subprocess.call(['cabal', 'repl', '--ghc-options="{} {}"'.format(odir, hidir)])
return
if sys.argv[1] == 'build':
log(sys.argv)
return
if sys.argv[1:] == ['exec', '--verbosity', 'silent', '--', 'ghc', '--supported-extensions']:
o = subprocess.check_output(["ghc", "--supported-extensions"])
print o
return
log(sys.argv)
raise Exception("unexpected intero command: {}".format(sys.argv))
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment