Skip to content

raku-community-modules/App-snippet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

App::snippet

run c/cpp or other language snippet code

Feature

  • Run code from command line arguments

  • Run code input from user

  • compile files and link them to executable binary

  • Preprocess code only

  • Compile code only

  • Code format

TODO

  • Run code grab from web

Language Support

  • c

  • c++

Usage

  • c

    • code snippet

      $ snippet c -e 'int a = 500;'  -e 'a = rand();' -e 'printf("%d\n", a);' -i stdlib.h -p
      --------------------------------------------------
      #include <stdlib.h>
      #include <stdio.h>
      int main(void)
      {
      int a = 500; a = rand(); printf("%d\n", a);
      return 0;
      }
      --------------------------------------------------
      1804289383
    • read from user

      $ snippet c -r
      Please input your code, make sure your code correct.
      Enter @@CODEEND input.
      int main() {
          printf("Hello World!!\n");
      }
      @@CODEEND
      Hello World!!
    • file

      $ snippet c *.c
      Hello World!!
  • cxx

    • code snippet

      $ snippet cpp -e 'int a{500};' -e 'std::random_device rd{};' -e 'std::uniform_int_distribution<int> dist(0, 100000);' -e 'a = dist(rd);' -e 'std::cout <<a << std::endl;' -p -i random
      --------------------------------------------------
      #include <random>
      #include <iostream>
      int main(void)
      {
      int a{500};
      std::random_device rd{};
      std::uniform_int_distribution<int> dist(0, 100000);
      a = dist(rd);
      std::cout <<a << std::endl;
      return 0;
      }
      --------------------------------------------------
      81873
    • read from user

      $ snippet cpp -r -p
      Please input your code, make sure your code correct.
      Enter @@CODEEND input.
      int main() {
          std::cout <<"Hello World" << std::endl;
      }
      @@CODEEND
      --------------------------------------------------
      #include <iostream>
      int main() {
          std::cout <<"Hello World" << std::endl;
      }
      --------------------------------------------------
      Hello World
    • file

      $ snippet cpp *.cpp
      Hello World!!

Installation

zef install App::snippet

License

GPL

Author

araraloren (blackcatoverwall#gmail.com)