From d48a2cc6f4ca34ca32247a643c9dbe32cba6dfc0 Mon Sep 17 00:00:00 2001 From: konard Date: Wed, 10 Sep 2025 16:35:47 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #24 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/link-foundation/link-cli/issues/24 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..7d2248f --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/link-foundation/link-cli/issues/24 +Your prepared branch: issue-24-3e3135c5 +Your prepared working directory: /tmp/gh-issue-solver-1757511344833 + +Proceed. \ No newline at end of file From 85731fae51695e0f6c3aa84343d1d2d753f26c59 Mon Sep 17 00:00:00 2001 From: konard Date: Wed, 10 Sep 2025 16:36:03 +0300 Subject: [PATCH 2/3] Remove CLAUDE.md - PR created successfully --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 7d2248f..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/link-foundation/link-cli/issues/24 -Your prepared branch: issue-24-3e3135c5 -Your prepared working directory: /tmp/gh-issue-solver-1757511344833 - -Proceed. \ No newline at end of file From c3ddbad079587c378153457105ac17a049c8f317 Mon Sep 17 00:00:00 2001 From: konard Date: Wed, 10 Sep 2025 16:53:17 +0300 Subject: [PATCH 3/3] Add --export option for LiNo file export MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added --export/-e option to CLI command structure - Implemented ExportToLinoFile function to export links data to LiNo format - Uses Platform.Protocols.Lino.IListExtensions.Format for proper LiNo formatting - Exports with named links when available, falls back to IDs - Version bumped to 2.3.0 for new feature 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../Foundation.Data.Doublets.Cli.csproj | 2 +- Foundation.Data.Doublets.Cli/Program.cs | 60 ++++++++++++++++++- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/Foundation.Data.Doublets.Cli/Foundation.Data.Doublets.Cli.csproj b/Foundation.Data.Doublets.Cli/Foundation.Data.Doublets.Cli.csproj index 1d8f9ab..e4d6c4d 100644 --- a/Foundation.Data.Doublets.Cli/Foundation.Data.Doublets.Cli.csproj +++ b/Foundation.Data.Doublets.Cli/Foundation.Data.Doublets.Cli.csproj @@ -15,7 +15,7 @@ link-foundation A CLI tool for links manipulation. clink - 2.2.2 + 2.3.0 Unlicense https://github.com/link-foundation/link-cli diff --git a/Foundation.Data.Doublets.Cli/Program.cs b/Foundation.Data.Doublets.Cli/Program.cs index 1f9bfed..aa96362 100644 --- a/Foundation.Data.Doublets.Cli/Program.cs +++ b/Foundation.Data.Doublets.Cli/Program.cs @@ -1,4 +1,5 @@ using System.CommandLine; +using System.IO; using Platform.Data; using Platform.Data.Doublets; using Platform.Data.Doublets.Memory.United.Generic; @@ -70,6 +71,12 @@ afterOption.AddAlias("--links"); afterOption.AddAlias("-a"); +var exportOption = new Option( + name: "--export", + description: "Export the links database to a LiNo file" +); +exportOption.AddAlias("-e"); + var rootCommand = new RootCommand("LiNo CLI Tool for managing links data store") { dbOption, @@ -79,11 +86,12 @@ structureOption, beforeOption, changesOption, - afterOption + afterOption, + exportOption }; rootCommand.SetHandler( - (string db, string queryOptionValue, string queryArgumentValue, bool trace, uint? structure, bool before, bool changes, bool after) => + (string db, string queryOptionValue, string queryArgumentValue, bool trace, uint? structure, bool before, bool changes, bool after, string exportFile) => { var decoratedLinks = new NamedLinksDecorator(db, trace); @@ -145,9 +153,14 @@ { PrintAllLinks(decoratedLinks); } + + if (!string.IsNullOrWhiteSpace(exportFile)) + { + ExportToLinoFile(decoratedLinks, exportFile); + } }, // Explicitly specify the type parameters - dbOption, queryOption, queryArgument, traceOption, structureOption, beforeOption, changesOption, afterOption + dbOption, queryOption, queryArgument, traceOption, structureOption, beforeOption, changesOption, afterOption, exportOption ); await rootCommand.InvokeAsync(args); @@ -189,4 +202,45 @@ static void PrintChange(NamedLinksDecorator links, DoubletLink linkBefore, var afterText = linkAfter.IsNull() ? "" : links.Format(linkAfter); var formattedChange = $"({beforeText}) ({afterText})"; Console.WriteLine(Namify(links, formattedChange)); +} + +static void ExportToLinoFile(NamedLinksDecorator links, string fileName) +{ + var exportLinks = new List>(); + var any = links.Constants.Any; + var query = new DoubletLink(index: any, source: any, target: any); + + links.Each(query, link => + { + // Get named representation if available, otherwise use ID + var sourceName = links.GetName(link.Source) ?? link.Source.ToString(); + var targetName = links.GetName(link.Target) ?? link.Target.ToString(); + + // Create LiNo Link with ID and source/target values + var linoLink = new Platform.Protocols.Lino.Link( + link.Index.ToString(), + new List> + { + new Platform.Protocols.Lino.Link(sourceName), + new Platform.Protocols.Lino.Link(targetName) + } + ); + + exportLinks.Add(linoLink); + return links.Constants.Continue; + }); + + // Export to LiNo format with clean formatting + string linoContent = Platform.Protocols.Lino.IListExtensions.Format(exportLinks, lessParentheses: true); + + try + { + File.WriteAllText(fileName, linoContent); + Console.WriteLine($"Exported {exportLinks.Count} links to {fileName}"); + } + catch (Exception ex) + { + Console.Error.WriteLine($"Error writing to file {fileName}: {ex.Message}"); + Environment.Exit(1); + } } \ No newline at end of file