text: #!/usr/bin/node
  // example in https://github.com/agentcooper/node-livejournal
  const LiveJournal = require("livejournal")
  const print = console.log;
  const fs = require('fs');
  
  // in $2=userid $3=postid   
  // out write files `/tmp/comments_${i}.json` comments structure of each page of comments
  // out write file /tmp/pagecount.txt N comment pages
  // out write file '/tmp/comments.html'  - just comment hierarchical 
  
  if (process.argv.length <=3 ) {
      console.log("Usage: ./xmlrpc_comments.js URL");
      process.exit(-1);
  }
  
  const userid = process.argv[2]; // 'alexcheban';
  const postid = process.argv[3]; // 356107;
  
  var pagecount = 1;
  var i=1; // current page
  
  /*
  var pages = []; // comment pages
  var onRender = function(data){
  	// files in /tmp
  	let ejs = require('ejs');
  	//ejs.root = __dirname;
  	let myFileLoad = function (filePath) {
  		print('filePath=',filePath);
  		return 'myFileLoad: ' + fs.readFileSync('./templates/'+filePath, {flag:'r'});
  	};
  	//ejs.includer = myFileLoad;
  	const tmpl = fs.readFileSync('./views/commentpages.ejs',
              {encoding:'utf8', flag:'r'});
      //print('___dirname', __dirname);
  	var s =	 ejs.render(tmpl, {pages: data ? [data] : pages}, { // pages 
  		root: __dirname,
  		views: ['views'],
  	}); 
  	//print(s);
  	fs.writeFileSync('/tmp/comments.html', s);
  	
  }
  */
   
  var onNextPage = function(err, value, isStart){
  	var req = function(){
  			LiveJournal.xmlrpc.getcomments({
  				auth_method: 'noauth',
  				itemshow: 200, 		//  (integer) – number of retrieved replies. By default set to 10
  				skip: 0,  			// (integer) – number of skipped replies. The parameter is used to define the number of replies displayed on each page. For example, when skip = 10, 10 most recent replies are displayed on the first page, replies 11-20 are displayed on the second page, etc. By  default, the parameter is set to 0
  									//  trim_widgets: 500, // s (integer) – number of symbols by which a reply is compressed (taking into account tag compression and images). The default is set to 50
  									//  widgets_img_length: 50, // h (integer) – number of symbols an image utilizes in a reply. If trim_widgets parameter specified. The default is set to 50
  				parseljtags: true , 	// converts embedded LJ-tags into simple HTML. The default is  set to false (0); when set to true (1), the system converts LJ-tags to plain HTML
  
  				journal: userid,
  				ditemid: postid, 
  				page: i,
  			}, onNextPage);
  	};
  	//print('err, value=', err, Object.keys(!!value ? value : {}) );
  	if(isStart)
  		req();
  	else
  		if(i>pagecount || !value || err){
  			//onRender();
  			return ;
  		}
  		
  	//print('page n=', i, ' pagecount=', pagecount);
  	
  	if(value){
  		// handle page
  		if(i==1){
  			pagecount = value.pages;
  			fs.writeFileSync('/tmp/pagecount.txt', ''+pagecount+"\n");
  			//print('pagecount=', pagecount);
  		}
  		//print('value=', value);
  		const s = JSON.stringify(value);
  		fs.writeFileSync(`/tmp/comments_${i}.json`, s);
  		//pages.push(value);
  		// go to next page
  		i += 1;
  		req();
  	}
  };
  
  const isStart = true;
  onNextPage(null, null, isStart);// lets start
  //onRender(JSON.parse(fs.readFileSync('_try/_data_xmlrpc_comments_of_alexcheban.json', {flag:'r'})));
  