October 13, 2014
On Mon, 06 Oct 2014 13:34:23 +0200
Martin Drašar via Digitalmars-d <digitalmars-d@puremagic.com> wrote:

> Ok, thanks for your answers. If you get your code to publishable state, I am sure a lot of people will be interested.
as i can't publish my current version of cmdcon, i decided to write another one from scratch. it contains alot less of mixin() codegens, can do everything cmdcon.d can do and has structs/classes already working. this is the excerpt from testing code:


import cong; // our console module

@ConName("intVar00")
@ConHelp("simple int variable")
@ConDescription("this is just an int variable.\nordinary one, nothing
special.")
__gshared int v0 = 42;

__gshared string v1 = "hi!";

class A {
  int i = 42;
  string s = "hello";
  this () {}
  this (string v) { s = v; }
  int bar () { writeln("BAR: s=", s); return 666; }
  void foo (float[] ff) {}
}

__gshared A a; // yes, this can be null

void foo (int n, string s="hi", double d=0.666) {
  writefln("n=%s; s=[%s]; d=%s", n, s, d);
}

struct S {
  int i = 666;
  string s = "bye";
  int sbar () { writeln("SBAR: s=", s); return 666; }
  void sfoo (float[] ff) {}
}

__gshared S s;
S s1;


void main (string[] args) {
  writeln("known commands:");
  foreach (auto n; conGetKnownNames()) writeln("  ", n);
  writeln("---");

  a = new A();
  conExecute("a bar"); // virtual method call for object instance
  a.s = "first change";
  conExecute("a bar");
  a = new A("second change");
  conExecute("a bar");  // virtual method call for ANOTHER object
  instance

  foreach (auto arg; args[1..$]) {
    try {
      writeln("# ", arg);
      conExecute(arg);
    } catch (Exception e) {
      writeln("***ERROR: ", e.msg);
    }
  }
}

mixin(ConRegisterAll); // register 'em all!

==========

known commands:
  intVar00
  a
  foo
  v1
  s
---
(autoregistration rocks!)

some sample commands and results:

# intVar00
intVar00 42 (Int)
# foo 42
n=42; s=[hi]; d=0.666
# a i
a.i 42 (Int)
# a bar
BAR: s=second change
# s sbar
SBAR: s=bye


by default `mixin(ConRegisterAll);` tries to register all suitable public symbols. one can use @ConIgnore UDA to ignore symbol and some other UDAs to change name, add help and so on. alas, there is no way to get Ddoc info in compile-time (what a pity!).

you can't register pointer objects (i.e. `__gshared int *a` will not
pass). it's doable (class fields are such objects internally), but i
just don't need this.

i also found some bugs in compilers (both dmd and gdc), but aren't ready to dustmite and report 'em yet. GDC just segfaults now, but DMD works.

there is also bug in CDGC, which took me a whole day of useless code motion (i forgot that i'm using DMD built with CDGC ;-).


so the base mechanics is in place, i need to debug some things and write simple sample with eventloop and telnet.

new code includes only WTFPL'ed parts, so it probably will be WTFPLed too.


hope to finish this until weekend.


October 13, 2014
Dne 13.10.2014 v 23:09 ketmar via Digitalmars-d napsal(a):
> as i can't publish my current version of cmdcon, i decided to write another one from scratch. it contains alot less of mixin() codegens, can do everything cmdcon.d can do and has structs/classes already working. this is the excerpt from testing code:

Nice! That's what I call a can-do attitude :) I just happen to have a nice place in code where it can get used. I'm looking forward for playing with it.

Martin



October 13, 2014
On Monday, 13 October 2014 at 21:09:29 UTC, ketmar via Digitalmars-d wrote:
> as i can't publish my current version of cmdcon, i decided to write another one from scratch.

Cool, looks like a fun module to play with! :-)
October 13, 2014
as i see that some peopele are eager to play with cmdcon-ng, i setup a git repo with it: http://repo.or.cz/w/cong.d.git

lay your hands while it hot!

the code is little messy (there are some napoleonian plans which aren't made into it), but it should work. at least with unittests and sample.

enjoy, and happy hacking!


October 13, 2014
On Tue, 14 Oct 2014 00:09:17 +0300
ketmar via Digitalmars-d <digitalmars-d@puremagic.com> wrote:

let's stop hijacking this thread. here is The Official Thread for
cmdcon-ng:
http://forum.dlang.org/thread/mailman.772.1413240502.9932.digitalmars-d@puremagic.com


March 17, 2016
On Friday, 3 October 2014 at 14:42:23 UTC, ketmar wrote:
> anyway, here it is: http://repo.or.cz/w/iv.d.git/blob_plain/HEAD:/cmdcon.d
>
> please note that this is not very well tested. i'm keeping it just for nostalgic reasons.
>
> ah, and you can ignore the license. consider that code as public domain/WTFPL.
>
> there is no struct/class support there, only variables and free functions. yet free functions supports various types of arguments and understands default agrument values.

Hi Ketmar.

I hope you're well.

Would you be able to share this again as not in repo now ?  I think I moved computer and lost the previous download.  No problem if you prefer not to, but I very much liked your idea and would like to take a quick look again to see what the main things to think about are (will write from scratch though).

Thanks.


Laeeth.
33 34 35 36 37 38 39 40 41 42 43
Next ›   Last »