Commit 161d6216 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

add 'img new' command

parent fac4f428
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
 * <http://www.gnu.org/licenses/>.
 */
#include <signaltk.h>
#include <signaltk/core/image_api.h>
#include <iostream>

namespace signaltk {
@@ -17,6 +18,7 @@ const std::vector<Command> command_list {
  // command: img new
  Command {
    .name = {"img", "new"},
    .fn = &cmd_image_new,
  },

};
@@ -36,7 +38,10 @@ int cmd(
      }
    }

    return 0;
    return cmd.fn(
        ctx,
        args + cmd.name.size(),
        arg_count - cmd.name.size());
  }

  return -1;
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ struct Context {

struct Command {
  std::vector<std::string> name;
  int (*fn)(Context*, const char**, int);
};

extern const std::vector<Command> command_list;
+2 −1
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ add_library(signaltk-graphics STATIC
    brush.cc
    colour.cc
    layer.cc
    text.cc)
    text.cc
    image_api.cc)

#add_executable(test-cplot chart_test.cc)
#target_link_libraries(test-cplot cplot stx-base)
+38 −0
Original line number Diff line number Diff line
/**
 * This file is part of the "signaltk" project
 *   Copyright (c) 2018 Paul Asmuth
 *
 * libstx is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. 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 <iostream>
#include <signaltk/util/flagparser.h>
#include "image_api.h"

namespace signaltk {

int cmd_image_new(Context* ctx, const char** args, int arg_count) {
  FlagParser flag_parser;

  std::string flag_out;
  flag_parser.defineString("out", true, &flag_out);

  uint64_t flag_width;
  flag_parser.defineUInt64("width", true, &flag_width);

  uint64_t flag_height;
  flag_parser.defineUInt64("height", true, &flag_height);

  auto rc = flag_parser.parseArgv(arg_count, args);
  if (!rc.isSuccess()) {
    std::cerr << "ERROR: " << rc.getMessage() << std::endl;
    return -1;
  }

  return 0;
}

} // namespace signaltk
+19 −0
Original line number Diff line number Diff line
/**
 * This file is part of the "signaltk" project
 *   Copyright (c) 2018 Paul Asmuth
 *
 * libstx is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. You should have received a
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#pragma once
#include <signaltk.h>
#include <signaltk/core/image.h>

namespace signaltk {

int cmd_image_new(Context* ctx, const char** args, int arg_count);

} // namespace signaltk
Loading