#!/usr/bin/env node

const stdin = require('get-stdin')
const parseTorrent = require('../')

function usage () {
  console.error('Usage: parse-torrent /path/to/torrent')
  console.error('       parse-torrent magnet_uri')
  console.error('       parse-torrent --stdin')
}

function error (err) {
  console.error(err.message)
  process.exit(1)
}

const arg = process.argv[2]

if (!arg) {
  console.error('Missing required argument')
  usage()
  process.exit(1)
}

if (arg === '--stdin' || arg === '-') stdin.buffer().then(onTorrentId).catch(error)
else if (arg === '--version' || arg === '-v') console.log(require('../package.json').version)
else onTorrentId(arg)

function onTorrentId (torrentId) {
  parseTorrent.remote(torrentId, function (err, parsedTorrent) {
    if (err) return error(err)

    delete parsedTorrent.info
    delete parsedTorrent.infoBuffer
    delete parsedTorrent.infoHashBuffer
    console.log(JSON.stringify(parsedTorrent, undefined, 2))
  })
}

@@ -262,16 +262,62 @@
 stdin')%0A
+  console.error('       parse-torrent --raw')%0A
 %7D%0A%0Afunct
@@ -834,16 +834,45 @@
 r(err)%0A%0A
+    if (arg !== '--raw') %7B%0A  
     dele
@@ -893,24 +893,26 @@
 nt.info%0A    
+ 
+ 
 delete parse
@@ -927,24 +927,26 @@
 .infoBuffer%0A
+  
     delete p
@@ -969,24 +969,30 @@
 oHashBuffer%0A
+    %7D%0A
     console.

add --raw flag