Blame view

Giac_maj/giac-1.4.9/src/aide.cc 2.68 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  // -*- mode:C++ ; compile-command: "g++ -I.. -g help.o aide.cc" -*-
  #ifdef HAVE_CONFIG_H
  #include "config.h"
  #endif
  #include "first.h"
  /*
   *  Copyright (C) 2000 B. Parisse, Institut Fourier, 38402 St Martin d'Heres
   *
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation; either version 3 of the License, or
   *  (at your option) any later version.
   *
   *  This program is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details.
   *
   *  You should have received a copy of the GNU General Public License
   *  along with this program. If not, see <http://www.gnu.org/licenses/>.
   */
  
  #include "help.h"
  #include "global.h"
  #include <iostream>
  using namespace std;
  using namespace giac;
  
  int main(int ARGC, char *ARGV[]){
    if (ARGC<2){
      cerr << "Syntax: " << ARGV[0] << " command_name" << endl;
      return 1;
    }
    // find current language: aide=1 (francais), help=2 (english), etc.
    int language=1;
    string current(ARGV[0]);  
    if (current=="fr_cas_help")
      language=1;
    if ( (current=="cas_help") || (current=="en_cas_help") )
      language=2;
    if (current=="es_cas_help")
      language=3;
    // read all help
    int count;
    vector<aide> v;
    giac::readhelp(v,"aide_cas",count,false);
    if (!count){
      if (getenv("XCAS_HELP"))
        giac::readhelp(v,getenv("XCAS_HELP"),count,true);
      else
        giac::readhelp(v,(giac::giac_aide_dir()+"aide_cas").c_str(),count,true);
    }
    multimap<string,string> mtt,mall;
    string html_help_dir("doc/");
    switch (language){
    case 1:
      html_help_dir +="fr/";
      break;
    case 2:
      html_help_dir +="en/";
      break;
    case 3:
      html_help_dir +="es/";
      break;
    }
    if (string(ARGV[1])=="*"){
      // output all example
      int s=v.size();
      for (int i=0;i<s;++i){
        cout << "//" << v[i].cmd_name << endl;
        int examples=v[i].examples.size();
        for (int j=0;j<examples;++j)
  	cout << v[i].examples[j] << ";" << endl;
      }
      return 0;
    }
  #ifndef EMCC
    find_all_index(html_help_dir,mtt,mall);
  #endif
    for (int j=1;j<ARGC;++j){
      // search for ARGV
      cout << "Help for " << ARGV[j] << ":" << endl;
      current = string(ARGV[j]);
      aide cur_aide=helpon(current,v,language,count);
      string result=writehelp(cur_aide,language);
      cout << result;
  #ifndef EMCC
      vector<string> v(html_help(mtt,current));
      vector<string>::const_iterator it=v.begin(),itend=v.end();
      for (;it!=itend;++it){
        cout << *it << endl;
      }
  #endif
    } 
    return 0;
  } // end main